Flask socketio failed error during websocket handshake unexpected response code 400

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Have a question about this project?

Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Already on GitHub? Sign in to your account.

flask-socketio 和 微信小程序 连接的坑 Error during WebSocket handshake: Unexpected response code: 400

I'm having trouble using socket io on one of my server machines. On my server side python code logging info, it shows that the server is emitting messages to the client, but on the client side, the client doesn't seem to receive anything. It also returns "failed: Error during WebSocket handshake: Unexpected response code: " sometimes. I tried on my own machine and it only works when I refresh the page the client page does not receive anything if I close it and open it again, but it does if I refresh it again.

I figured the problem was probably with eventlet. When using eventlet, the client page keeps loading for a while and on the server side, it shows that the client keeps connecting and disconnecting for several times and eventually, the client console pops an error "websocket connection failed: Invalid frame header" with a error. Then it starts to work but then continues to connect and disconnect But when I uninstalled eventlet and switch to gevent, it works fine.

No connection error. It works well with the default Werkzeug. You are probably not using websocket after you switched out of eventlet. I doubt eventlet is the problem, I'm guessing something prevents websocket connections to be established. I tried on three machines, all having the same issue. Two of them are ubuntu and the other one is a Mac.

I also tried different ports. But I'm running the server directly through python and hosting the html and static files with flask. But the connections go through Apache? Have you configured it to proxy websocket connections in addition to HTTP?

WebSockets (using zkfingerrenault.fun) Tutorial #4 - Emitting Messages

I think the connections go through Apache, but I don't think I configured it to proxy websocket connections. There's no "websocket. Well, apache is particularly difficult to get to proxy websocket connections. I don't use it myself, but I have heard many times of people not being able to set it up to work. On the other side, nginx is fairly easy to set up, you can find an example configuration in the documentation. I tried to configure apache, but it sends me the "socket.

I guess I'll just make do with using gevent for now. IO protocol. If you look at the nginx configuration in the documentation you will see that it is also handled as a specific location. For nginx you have to add additional setting to get the proxying to work on websocket.

In this page it appears you also have to use additional configuration for Apache. I'll have to figure out a way to work with nginx along side with apche then, someone else is using apache on the server. If gevent is not using websocket, what is it using?My code is very straightforward - on the client side I am calling this. I have noticed several related posts on this topic, and have tried a ton of variations, but nothing seems to work.

Thanks in advance :. You need to listen for connections to the socket and then you can create a new Sockets instance after having received one from Socket. Then you can store the socket received from Socket. Why am I getting the errorwhen the fetch url is ok? Dot notation in React imports. How to fix after attempt to override existing POST?

Dynamic Object Reference in Object. Altering element's content in javascript. I am running my node application on Google consoleAfter the node server starts for about 30 seconds, and this error is shown on the console. I currently have a large database, and I need a means of backing up subsets of the data that can then be imported on another mongodb instance.

Home Node. Get unique users ids to get list of users with latest conversation. Import html table into google sheets using google apps script. Laravel Auth register route or login route not found.Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you may not be able to execute some actions. Please download a browser that supports JavaScript, or enable it if it's disabled i. By default, NodeBB only allows websocket connections from the "url" value in config.

This is because of what is called Cross-Site Websocket Hijacking. By restricting the origin at which sockets can connect, we prevent this attack from taking place.

If the issue disappeared when visiting your site running in dev mode, then your problem is in fact an origin mismatch.

flask socketio failed error during websocket handshake unexpected response code 400

If not, it is likely something else, so look around or ask a question here on the forum. The easiest solution is to set the "url" value in config. For instance, the configuration for this site is. If you want your forum to work from multiple origins like www. For instance, redirect www. If you absolutely must have full access from multiple origins, you can configure the accepted origins directly. As documented hereyou can add a socket.

For example, to allow accessing the forum sockets from the main NodeBB site, nodebb. It's likely a reverse proxy configuration issue. Take a look at the proxy documentation for examples. If you still have issues, ask a question here on the forum. Register Login. Only users with topic management privileges can see it. Diagnosis To make sure that your issue is in fact caused by an origin mismatch, try this: Stop the NodeBB server:. Solutions The easiest solution is to set the "url" value in config.

Still having issues? Reply Quote 3 1 Reply Last reply. Loading More Posts 1 Posts. Reply Reply as topic. Suggested Topics. Focus on this thread! The audience will have three choices to pick from a bit. Only I will be able to see the overall results submitted. Would it be possible to get the ip addresses of the people who have voted?

Is there a sample app. I can reuse? Inside of the forum? Updated to latest fais cfrancois Kev-M.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Can't find out a solution. I'm not a lot into apache configs, but I currently need this to reroute to local server.

I'm using solution for the reroute found somewhere in the internet. It worked. I have a connection, but I'm getting this error. WebSocket handshake: Unexpected response code: Learn more. WebSocket handshake: Unexpected response code: Ask Question. Asked 2 years, 9 months ago. Active 1 year, 2 months ago. Viewed 2k times. Weird, I would not expect the RewriteRule to match in Location context.

Can you share a more complete sequence of full logs? I would remove all of this from Location context and follow a more basic example. Please see stackoverflow. Active Oldest Votes. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Programming tutorials can be a real drag. Featured on Meta. Community and Moderator guidelines for escalating issues via new response….

Feedback on Q2 Community Roadmap. Technical site integration observational experiment live on Stack Overflow. Dark Mode Beta - help us root out low-contrast and un-converted bits. Linked GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

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

Already on GitHub? Sign in to your account. Hi, I have no idea why my app with websocket works well when I test it on my local machine, but it won't connect when deploying on server.

It keep displaying this error:. I am guessing the problem is on my nginx config. I use eventlet by the way, here is my nginx conf:. Can you try changing your eventlet server to listen on 0. I've tried to run the eventlet with this command:.

But nothing change. I found that when I run the eventlet, it works well at first, the connection is established, but suddenly it will stop and give the error above on the client. I try to see the log, it gives me this error:. After two days trying to figure out what happened. It also causes error above, it will disconnect itself when the port is being blocked. Skip to content. Dismiss Join GitHub today GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Sign up. New issue. Jump to bottom. Copy link Quote reply. This comment has been minimized. Sign in to view. The nginx config looks okay, at least I don't see anything odd in there. I've tried to run the eventlet with this command: gunicorn --worker-class eventlet -w 1 -b 0. QueueEmpty engineio. Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment. Linked pull requests. You signed in with another tab or window.

Subscribe to RSS

Reload to refresh your session. You signed out in another tab or window.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Any suggestions for this, irrespective of research I couldn't find any solution to this problem, any idea what went wrong on this and how can it be fixed.

flask socketio failed error during websocket handshake unexpected response code 400

Learn more. Socket IO unexpected response code during handshake Ask Question.

Subscribe to RSS

Asked 5 years, 5 months ago. Active 5 years, 5 months ago. Viewed 1k times. Hello did you find the solution for this? I commented root request app.

flask socketio failed error during websocket handshake unexpected response code 400

Active Oldest Votes. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Programming tutorials can be a real drag. Featured on Meta. Community and Moderator guidelines for escalating issues via new response…. Feedback on Q2 Community Roadmap. Technical site integration observational experiment live on Stack Overflow. Dark Mode Beta - help us root out low-contrast and un-converted bits.

Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

I kept thinking this was a flask-socketio error but reading similar problems online makes me think this is a socketio error. Any one knows how to proceed with this? Learn more.

Asked 4 years, 3 months ago. Active 1 month ago. Viewed 2k times. This seems similar to some unanswered questions on stack overflow.

I am running a python socketio app on heroku and I get this error when I launch the website : Error during websocket handshake Unexpected response code: I kept thinking this was a flask-socketio error but reading similar problems online makes me think this is a socketio error. Denny George Denny George 1 1 gold badge 4 4 silver badges 14 14 bronze badges. Active Oldest Votes. Downgrading to That1Guy 5, 4 4 gold badges 43 43 silver badges 51 51 bronze badges. Sign up or log in Sign up using Google.

Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Programming tutorials can be a real drag.