linuxシステム構築websocket注意事項

1635 ワード

ここでは、独自の2つの異なるサーバで構築されたプロセスサーバ1について説明します.
西部デジタルサーバ:ubuntu-14.04.外部ネットワークip:21.1129.205.111イントラネットワークip:192.168.205.41
指定したサイトにコードをアップロードします.サーバファイルを実行し、正常に実行し、リスニングします.万事順調だ.サーバ2
アリクラウドサーバ:centos 7.外網ip:21.68.26.26.22内網ip:172.28.219.158
指定したサイトにコードをアップロードしてwebsocket端末を実行すると、いつも次のエラーが表示されます.ipは、傍受に使用できる外部ネットワークipに変更されます.
[root@houxin socket]# php server.php
PHP Warning:  socket_bind(): unable to bind address [99]: Cannot assign requested address in /www/wwwroot/socket/websocket.class.php on line 64

Warning: socket_bind(): unable to bind address [99]: Cannot assign requested address in /www/wwwroot/socket/websocket.class.php on line 64

リスニング開始:121.68.26.22:8000常時socket_bind()この関数バインドにエラーが発生しました.前にインターネットで探しても理由が見つからない.また、サーバ1では正常に使用できます.これで呆然とした.インターネットの検索を経て、このような答えが見つかりました.
You cannot bind to the external IP, you have to bind to the internal IP, and setup a rule to allow that port so when they connect to the external IP and port, it gets redirected to the internal IP.
そこでサーバのwebsocketを作成したipを内部ipに変更してみました.やはり成功した.ここで自分に注意して、みんなにも模範を示します.サーバの環境が異なるため、さまざまな方法で解決策を試みます.