问题描述
我的前端将HTTP请求发送到同一台计算机上的后端,例如,登录到以下URL的POST请求:http://192.168.178.202:3001/signin
不幸的是,当时间超过一定时间后,请求会停留在挂起状态并失败。我的后端使用的是puma,我是这样开始的:
$ bundle exec puma -C /var/www/simple-organizer/current/config/puma.rb
[27805] Puma starting in cluster mode...
[27805] * Version 4.3.5 (ruby 2.7.1-p83),codename: Mysterious Traveller
[27805] * Min threads: 5,max threads: 5
[27805] * Environment: production
[27805] * Process workers: 4
[27805] * Preloading application
[27805] * Listening on unix:///var/www/simple-organizer/current/shared/sockets/puma.sock
[27805] * Listening on tcp://0.0.0.0:3001
我还从定义的显式IP开始:
$ bundle exec puma -b tcp://192.168.178.202:3001 -C /var/www/simple-organizer/current/config/puma.rb
[1729] Puma starting in cluster mode...
[1729] * Version 4.3.5 (ruby 2.7.1-p83),codename: Mysterious Traveller
[1729] * Min threads: 5,max threads: 5
[1729] * Environment: production
[1729] * Process workers: 4
[1729] * Preloading application
[1729] * Listening on tcp://192.168.178.202:3001
但不幸的是,前端应用程序没有请求到达服务器。 Netstat确认服务器正在运行:
$ sudo netstat -tulpn
Aktive Internetverbindungen (Nur Server)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 633/nginx: master p
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 481/sshd
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 633/nginx: master p
tcp 0 0 0.0.0.0:3001 0.0.0.0:* LISTEN 10142/puma: cluster
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 544/mysqld
tcp6 0 0 :::22 :::* LISTEN 481/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 415/dhcpcd
udp 0 0 0.0.0.0:5353 0.0.0.0:* 388/avahi-daemon: r
udp 0 0 0.0.0.0:52558 0.0.0.0:* 388/avahi-daemon: r
udp6 0 0 :::546 :::* 415/dhcpcd
udp6 0 0 :::40677 :::* 388/avahi-daemon: r
udp6 0 0 :::5353 :::* 388/avahi-daemon: r
还通过执行以下操作来允许防火墙上的端口:
$ sudo iptables -A INPUT -p tcp --dport 3001 -j ACCEPT
$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:3001
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
还尝试了sudo iptables -F
来彻底消除防火墙问题。
我真的很感谢任何帮助!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)