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

Websocket: Attempt to decode JSON with unexpected mimetype: text/plain; charset=utf-8 #2

Open
wjmelements opened this issue Dec 18, 2020 · 1 comment

Comments

@wjmelements
Copy link

I am trying to use a websocket uri for the sdk. Maybe it's not supported, but here is the error. I did not see the error when using http.

Version 0.0.4.

Traceback (most recent call last):
  File "~/.local/share/virtualenvs/prj-XTuW3tpY/lib/python3.7/site-packages/defisdk/repositories/ethereum.py", line 24, in call_method
    node_answer = await self._post(url=self.url.url, headers=headers, data=data)
  File "~/.local/share/virtualenvs/prj-XTuW3tpY/lib/python3.7/site-packages/defisdk/repositories/base.py", line 18, in _post
    return await r.json()
  File "~/.local/share/virtualenvs/prj-XTuW3tpY/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 1103, in json
    headers=self.headers,
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain; charset=utf-8', url=URL('ws://192.168.0.15:8546')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "~/.local/share/virtualenvs/prj-XTuW3tpY/lib/python3.7/site-packages/defisdk/repositories/ethereum.py", line 26, in call_method
    raise EthereumNodeResponseException(params, e.message, e.code, e.response)
AttributeError: 'ContentTypeError' object has no attribute 'response'

During handling of the above exception, another exception occurred:
    
    ...

     = await defi_sdk.get_token_components(
  File "~/.local/share/virtualenvs/prj-XTuW3tpY/lib/python3.7/site-packages/defisdk/__init__.py", line 84, in get_token_components
    return await self._repository.get_token_components(token_type, token_address, block)
  File "~/.local/share/virtualenvs/prj-XTuW3tpY/lib/python3.7/site-packages/defisdk/repositories/defi.py", line 187, in get_token_components
    full_token_balance = await self.get_full_token_balance(token_type, token_address, block)
  File "~/.local/share/virtualenvs/prj-XTuW3tpY/lib/python3.7/site-packages/defisdk/repositories/defi.py", line 159, in get_full_token_balance
    block=block
  File "~/.local/share/virtualenvs/prj-XTuW3tpY/lib/python3.7/site-packages/defisdk/repositories/ethereum.py", line 42, in _call
    node_answer = await self.call_method('eth_call', params)
  File "~/.local/share/virtualenvs/prj-XTuW3tpY/lib/python3.7/site-packages/defisdk/repositories/ethereum.py", line 28, in call_method
    if not node_answer.get('result'):
AttributeError: 'NoneType' object has no attribute 'get'
@bashalex
Copy link
Member

Hey @wjmelements, thanks for reporting!
Web socket URIs are indeed not supported atm but it's a great feature request for the future versions.

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

No branches or pull requests

2 participants