I have application created in react and i am using socket.io-client library for Connection.
When i am trying to deploy my app on prod the socket is not connecting.
Here is my frontend socket config:-
const socket = io.connect(socketBaseUrl, { extraHeaders: { "Access-Control-Allow-Origin": "*", }, transports: ["websocket", "polling"], // I need to use websocket (not polling) });
Connection error message getting in console
I have tried many different ways but no success.
- transports: [“polling”] -> working fine in prod
- transports: [“websocket”, “polling”] -> not working when i first add websocket
Is there something which i have missed?
Application specs : MERN stack
Deployed : AWS ec2 instance with nginx
Socket Package: socket.io-client for Frontend & socket.io for Backend
You have not included enough detail to be helped. In particular you left off whatever the error message you’re getting and details of how your application is deployed
I am not getting any error message, rather than connecting phase pending i have updated above issue
@KevalDevganiya, your details seems appropriate but want to understand if polling is working what is the need of web socket?
@HARDIKTHAKOR Polling intent to make API calls but I need to establish a connection via WS