Skip to content
Advertisement

electron/socket.io client – python-socketio/aiohttp server // fail to connect

This websocket connection fails. The funny thing is this was working a couple days ago. I downgraded electron from 6 to 5.0.6 but this didn’t help.

enter image description here enter image description here

Server

JavaScript

Client (also tested from pure node)

JavaScript

When I try it in the browser, I get cors error. Thus, I allowed cors which made it work

JavaScript

When I run this from electron/node now, I get the same error as initially plus a key error: enter image description here

Since it was working before, and now it doesn’t on 2 different machines and with a minimal example project, I have no idea what could cause all of this.

Please help me stack people.

Advertisement

Answer

2021: Note that you can now install again from pypi. You still need to allow cors.

After a chat with Miguel Grinberg on twitter, I found out how to set it up. There are a couple of things. First 4.3 introduced CORS restriction by default. There was a bug with CORS headers from node client, since node is not a browser. That is fixed by now.

However, it is still not enough to simply pip install python-socketio You have to install the master branch of python-enginio manually as there is the CORS header fix.

My Pipfile looks like this:

JavaScript

Dont forget to allow CORS now serverside.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement