Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: expected string or bytes-like object #77

Open
sergioteula opened this issue Mar 26, 2019 · 7 comments
Open

Error: expected string or bytes-like object #77

sergioteula opened this issue Mar 26, 2019 · 7 comments
Assignees
Labels

Comments

@sergioteula
Copy link

I'm running my code on a server, and the connection to Amazon works correct when I first boot at the server, but after some requests it fails all the time. If I restart the server it starts working again, but then fails on the same previous situation. I've tried changing the IP from the server, to check if my IP was blocked. But that wasn't the case. I'm not getting a clear error from the API, only an empty object error, so I can't figure out how to solve the issue.

Here is the error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/amazon/api.py", line 174, in lookup
    response = self.api.ItemLookup(ResponseGroup=ResponseGroup, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/bottlenose/api.py", line 274, in __call__
    {'api_url': api_url, 'cache_url': cache_url})
  File "/usr/local/lib/python3.5/dist-packages/bottlenose/api.py", line 235, in _call_api
    return urllib2.urlopen(api_request, timeout=self.Timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 466, in open
    response = self._open(req, data)
  File "/usr/lib/python3.5/urllib/request.py", line 484, in _open
    '_open', req)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 1297, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.5/urllib/request.py", line 1254, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/lib/python3.5/http/client.py", line 1107, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1147, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.5/http/client.py", line 1083, in putheader
    if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object

Thanks!

@dlo dlo self-assigned this Mar 26, 2019
@dlo dlo added the bug label Mar 26, 2019
@dlo
Copy link
Member

dlo commented Mar 26, 2019

@sergioteula Very weird! Can you confirm that after a response fails on the server, that it works locally immediately afterwards?

@sergioteula
Copy link
Author

@dlo I have used bottlenose to retrieve the same product on my server, which has been running for a while, and my PC with a fresly started instance of my app, both at the same time. The result is that on my server I get the same error posted above, but on my PC the result is correct and I get the information about the product. That should mean that my account is correct and there's something else going on...

@sergioteula
Copy link
Author

@dlo I have just confirmed that it's not necessary to restart the server in order to make the API work again, I only need to stop running the code and start it. I don't know if this helps to find the issue, I hope so. Let me know if you want me to do any other test. Thanks a lot!

@dlo
Copy link
Member

dlo commented Mar 27, 2019

@sergioteula Hmm, since it works locally in all cases, and it works on your server intermittently, my guess is that there must be something different on your server environment. Any idea what it could be?

@sergioteula
Copy link
Author

@dlo That's not the case, it worked on my PC because I started running the code at that moment, but after some time it fails too. So it fails both at the server and on my PC. My previous test was to demonstrate that it's not an Amazon API limitation.

@dlo
Copy link
Member

dlo commented Mar 27, 2019

Gotcha. I'm stumped then. I haven't heard this happening before so I'm wondering if there's something else going on. Any potential firewall that could be affecting both your local environment and the server?

@sergioteula
Copy link
Author

@dlo I don't think so... It has started to fail some days ago, it was working perfectly until now. The strange thing is what I said, stopping running the code and starting it again solves the issue for a moment. Can I send you any extra information?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants