Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Websocket proxy setting in Nginx #217

Open
sspsinha opened this issue Jan 31, 2020 · 6 comments
Open

Issue with Websocket proxy setting in Nginx #217

sspsinha opened this issue Jan 31, 2020 · 6 comments

Comments

@sspsinha
Copy link

No description provided.

@sspsinha
Copy link
Author

/WebSocket connection to 'ws://localhost:9097/graphql' failed: Error during WebSocket handshake: Unexpected response code: 405

/Issue while hosting the graphql server on nginx

/Nginx.config websocket server setting

            listen       9097;
	server_name  localhost;
	location /subscription{			
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_pass http://localhost:3007;
	}

My graphql server is running locally on localhost:3007/graphql. But with above configuration socket is not getting created.

Getting below error:

WebSocket connection to 'ws://localhost:9097/graphql' failed: Error during WebSocket handshake: Unexpected response code: 405.

@sannge
Copy link

sannge commented Feb 9, 2021

same issue here, getting this error from frontend, client.ts:557 WebSocket connection to 'ws://localhost:8080/graphql' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

here is my setup,
server { location / { proxy_pass http://web:8080; } }

@bahachammakhi
Copy link

Any solution for this @sannge @sspsinha ?

@Cigan12
Copy link

Cigan12 commented Feb 2, 2022

@bahachammakhi any solution?)

@Cigan12
Copy link

Cigan12 commented Feb 2, 2022

I have this configuration for nginx
image
And this one in nestjs
image
And the postman returns 400 when I'm trying to connect
image

For browser the same

@Cigan12
Copy link

Cigan12 commented Feb 8, 2022

So, I've found the solution, the problem was in postman, I don't know why, but websockets there is working inappropriate, btw, some problem was with nginx, I had two of them, on inside the docker container and the second main on the server, and I need to add the same thing (proxy_set_header etc.) to both of nginxs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants