Home > Net >  not able to establish socket connection with server running on different port based on path/endpoint
not able to establish socket connection with server running on different port based on path/endpoint

Time:03-16

client --

var socket = io(
{
  transports : ['polling'],
  path : '/mysocket'
});

server--

io = require('socket.io')(server,{
   path : '/mysocket'
});

nginx --

location /socket/ {
  proxy_pass http://example.com:3005
}

https://example.com is running on two ports 3003 & 3005 all endpoints are connected to 3003 and my end point is connected to 3005 where my socket connections will be done,but the the socket is not connecting to 3005 instead it is connecting to 3003.

CodePudding user response:

it was nginx where i was missing i need to add

location /socket/ {
  proxy_http_version 1.1
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_pass http://example.com:3005;
}

this solved my issue

  • Related