In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about how to solve the problem of sockjs-node error. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The solution of sockjs-node error: 1, configure port 9097 on nginx; 2, let "/ sockjs-node" be able to proxy to the actual port of this machine normally.
This article operating environment: Windows7 system, nodejs10.16.2 version, Dell G3 computer.
How to solve the problem of sockjs-node error reporting?
Solution of sockjs-node Interface error reporting
Project background
When taking over other people's angular projects (vue.js may also encounter this problem), in order to solve the problem that the cross-domain front end is configured with nginx, after the project starts, the backend ws reports an error, as shown below:
Problem location:
Find out the cause of the error on the Internet and find that sockjs-node is the interface of nodejs hot loading for browser and local communication, and the hot loading function is invalid at this time. Therefore, the reason for the error is that this communication interface accesses port 9097 of the nginx agent instead of port 8082 started by the actual service, so it cannot communicate.
Solution:
Configure on nginx to configure this port 9097 so that / sockjs-node can properly proxy to the actual port of the machine, thus solving the problem.
Specific measures:
Add nginx configuration to nginx
Http {include mime.types; default_type application/octet-stream; map $http_upgrade $connection_upgrade {default upgrade;''close;} server {listen 9097; server_name localhost; location / sockjs-node {proxy_pass http://0.0.0.0:8082; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade }}
Note: the most important thing about the above is that the following two lines are added to the configuration of the reverse proxy, and the other parts are no different from the ordinary HTTP reverse proxy.
Roxy_set_header Upgrade $http_upgrade
Proxy_set_header Connection $connection_upgrade
The key part of this is that the following header is added to the request of HTTP:
Upgrade: websocket
Connection: Upgrade
These two fields indicate that the server upgrade protocol is requested to be WebSocket.
Conclusion
In fact, there may be many reasons for the / sockjs-node error, such as shadowsock proxy, nodejs configuration, etc. As long as you understand the nature of the problem and correctly let ws access the actual local address.
Thank you for reading! This is the end of the article on "how to solve the problem of sockjs-node error reporting". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.