Re: Two websocket connections at the same time

Lubos, Robert

Hi Mike,


You need to increase “CONFIG_WEBSOCKET_MAX_CONTEXTS” in order to create more websocket connections, this config defaults to 1. I’m not sure if you open any other sockets in your application, but you might also consider increasing “CONFIG_POSIX_MAX_FDS”, the default value is 4, and each websocket will use 2 file descriptors – one for the underlying TCP socket, and other for the actual websocket “socket”.





From: users@... <users@...> On Behalf Of Michael Federer via
Sent: wtorek, 12 października 2021 15:57
To: users@...
Subject: [Zephyr-users] Two websocket connections at the same time


Hi all,


I try to open two websocket connections and keep them connected to a FastAPI server at the same time. Establishing the first websocket connection seems to work. But establishing the second connection stucks immediately after the socket for the HTTP handshake was created successfully. The second websocket_connect seems to fail.


Here some details.

1st connection:

- HTTP socket id: 0

- Websocket id: 1


2nd connection:

- HTTP socket id: 2

- Websocket id: -2 (looks like an error code)


Some further details:

- Zephyr version: 2.5.99


Maybe my prj.conf lacks a necessary entry.

Does anyone have experience with multiple websockets at the same time? I really appreciate your help.


Cheers, Mike




Join to automatically receive all group messages.