Skip to content

Connecting to socket.io: 400 Bad Request "unknown transport "undefined"" #19

@alexwohlbruck

Description

@alexwohlbruck

I am trying to connect to my socket.io server, and Socket.io is returning a 400 error with the message unknown transport "undefined". It seems that the transport query param needs to be set. I tried setting it to websocket and polling but neither seem to get me anywhere. I don't know much about the connection protocol, but why might this be happening?

Server log:

listening on *:3000
  engine intercepting request for path "/socket.io/" +0ms
  engine handling "GET" http request "/socket.io/?EIO=3" +1ms
  engine unknown transport "undefined" +2ms

Micropython log:

b'GET %s HTTP/1.1' /socket.io/?EIO=3
b'Host: %s:%s' 192.168.86.31 3000
b''
Traceback (most recent call last):
  File "main.py", line 36, in <module>
  File "main.py", line 27, in main
  File "main.py", line 20, in hello
  File "usocketio/client.py", line 78, in connect
  File "usocketio/client.py", line 43, in _connect_http
AssertionError: b'HTTP/1.1 400 Bad Request'
MicroPython v1.18 on 2022-01-17; ESP32 module with ESP32
Type "help()" for more information.

My code, from example:

with usocketio.client.connect('http://192.168.86.31:3000') as socketio:
   @socketio.on('message')
   def on_message(self, message):
        print("message", message)

socketio.run_forever()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions