Forums

unable to create a websocket

Hi we are developing using the leap motion controller

leap motion uses a script that creates a websocket, they have stated profusely that with their new fix that although it creates a ws it has a fix that allows it to pass through https, so i am looking here/asking to see if perhaps the reason i am still having a problem is that something on the python anywhere side is stoping the script from running?

Are you trying to create a WebSocket connection from PythonAnywhere (the client) to a server somewhere else? If that's the case, then the problem may be that you have a free account and the server isn't on our whitelist. If it has a publicly accessible API, let us know and we'll add it. It might work then, though that depends on how good their HTTPS tunnelling code is.

If you're trying to create a WebSocket server running on PythonAnywhere then that won't work right now. It's on our to-do list but won't happen for some time.

I believe that we are, in our view on web2py for a game for instance we have a script eg.. <script src="//js.leapmotion.com/leap-0.6.2.js"></script> the code in this script creates a ws to an ip they host I think. does that help answer the question at all?

That sounds like it would bypass PythonAnywhere completely, then -- although your view page is coming from PythonAnywhere, the WebSocket (or tunnelled HTTPS connection) would go directly from your user's browser to the IP address you specify. So nothing on the PythonAnywhere side would be affecting it.

Probably the best thing to do is to look at the JavaScript console in the browser, and get in touch with the Leap Motion people.

thanks

to be thorough, this is the error we receive

[blocked] the page at 'https://csuargames.pythonanywhere.com/....../' was loaded over HTTPS, but ran insecure content from 'ws://127.0.0.1:6437/v6.json': this content should also be loaded over HTTPS.\n Uncaught Security Error: Failed to construct 'WebSocket' : An insecure websocket connect may not be initiated from a page loaded over HTTPS.

Ah, that makes sense. If you visit your page over HTTP instead of HTTPS then it should work. It looks like their code is trying to create a non-secure WebSocket ("ws:") instead of a secure one ("wss:")

I have a Slack bot that uses the Python-SlackClient and I am experiencing the same issue with this part of the library:

https://github.com/slackhq/python-slackclient/blob/master/slackclient/_server.py#L110

It throws the error: AttributeError: 'NoneType' object has no attribute 'recv'

What can I do about this, please?

Hi there,

How are you running your slack bot? (eg: from the console?) For free users, you wouldn't be able to establish a websocket connection through the proxy.

Here is a working implementation of a slack bot on PythonAnywhere which doesn't use websockets (every time anything happens, slack just hits your webapp endpt and you give it a response)

Conrad

@conrad,

Thank you. Well I have run the app from both the terminal, and by modifying the wsgi file like so: https://gist.github.com/takwas/bf857674b8e02d889fa06c0d6ed60504

Either way, I continue to hit the same error.

My project is at: https://github.com/takwas/votebot

For free users, you wouldn't be able to establish a websocket connection through the proxy. Try upgrading.

Okay. Thank you for your support.