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

AttributeError: module 'geventwebsocket' has no attribute 'create_connection' #100

Open
vojtooo opened this issue May 5, 2022 · 1 comment

Comments

@vojtooo
Copy link

vojtooo commented May 5, 2022

I want to connect RPCClient that uses JSONRPCProtocol and HttpWebSocketClientTransport.

I have installed everything using
pip install tinyrpc[websocket]

And then created minimal example

from tinyrpc.client import RPCClient
from tinyrpc.protocols.jsonrpc import JSONRPCProtocol
from tinyrpc.transports.websocketclient import HttpWebSocketClientTransport
from tinyrpc.transports import ClientTransport

def jsonRpcClientProxy(ip, port, one_way=False):
    url = "http://" + str(ip) + ":" + str(port)
    print(url)
    client = RPCClient(JSONRPCProtocol(), HttpWebSocketClientTransport(url))
    return client.get_proxy(one_way=one_way)

When I call jsonRpcClientProxy I get

File "XX.py", line 9, in jsonRpcClientProxy client = RPCClient(JSONRPCProtocol(), HttpWebSocketClientTransport(url)) File "YY/venv/lib/python3.8/site-packages/tinyrpc/transports/websocketclient.py", line 25, in __init__ self.ws = websocket.create_connection(self.endpoint, **kwargs) AttributeError: module 'geventwebsocket' has no attribute 'create_connection'

Is this some library mismatch?

@lnoor
Copy link
Collaborator

lnoor commented May 8, 2022

I've personally never used websockets; this code was already part of tinyrpc when I took over.
However checking the code I believe you are including the wrong dependencies.
Try pip install tinyrpc[httpclient] instead of pip install tinyrpc[websocket].
'http' includes the package websocket-client which does provide a create_connection method.

It looks like pip install tinyrpc[websocket] is used only when creating a websocket based server.
I'm not sure that still works though as the gevent-websocket package it fetches from pypi hasn't been updated in 5 years.
If you have the time and knowledge I would greatly appreciate if you could verify that the websocket server still works with python 3.

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