Unexpected server response: 502

Hello i’m trying to connect a project with a anthor project by websocket but i get
Unexpected server response: 502

This is my code

const wss = new ws(config.wsURI);

wss.on(‘open’, async () => {
wss.on(‘close’, async() => {

wss.on(‘message’, async (data) => {

wss.on(‘error’, (err) => {

This post was flagged by the community and is temporarily hidden.

Anything else in the logs?

You gotta have it send a User-Agent header. If you don’t send that, Glitch will reject the request before it even gets to your app, long before your app can perform the upgrade to websocket. Coincidentally, if a request to upgrade to websocket is not successfully upgraded, another part of Glitch or AWS or something breaks and you get a 502 back, which annoyingly swallows any other error information.


thank you very much for your help