arthurkushman / php-wss

Web-socket server/client with multi-process and parse templates support on server and send/receive options on client
MIT License
210 stars 32 forks source link

Invalid server upgrade response and bad opcode #77

Open sourcefrom opened 1 year ago

sourcefrom commented 1 year ago

Hi,

My code worked fine till about 10 days ago, when I suddenly couldn't connect to a third party websocket server. The following is the error log, various system version info (I redacted a bit just to get rid of some repeated errors).

Upon some invistigation, here are some initial suspcions, but I was unable to pinpoint exactly where the problem is:

third party web server is up and running, and my code worked till 5 days ago googled "failed: Server sent invalid upgrade response:", but couldn't find actionable clues Would apprecaite some insights on how to fix this.

Thanks!

[OS] Linux iZ2ze55czz7lmt0i16nhmjZ 3.10.0-1062.1.2.el7.x86_64 https://github.com/arthurkushman/php-wss/issues/1 SMP Mon Sep 30 14:19:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

[curl] curl 7.78.0 (x86_64-pc-linux-gnu) libcurl/7.78.0 OpenSSL/1.1.1k zlib/1.2.7 OpenLDAP/2.4.44 Release-Date: 2021-07-21 Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: alt-svc AsynchDNS HSTS HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets

[error log]

[2022-11-17 15:39:40] local.INFO: Connection to 'wss://stream.xxxxxxxbeta.com/so cket/websocket?token=mytoken' failed: Server sent inval id upgrade response: HTTP/1.1 504 Gateway Time-out Date: Thu, 17 Nov 2022 07:39:37 GMT Content-Type: text/html Transfer-Encoding: chunked Connection: keep-alive Set-Cookie: AWSALB=NwSlIprdUM9DuDngcfYNsWXnH41AGiHSNRmxgqXAt/brpofXK2+Mz+ia9AekK /DRy1A7f0DBNY7EI+xGb94Mps9NORNNbY40Ox7PAcjA5Wacp3H1lMcoFu6pBb59; Expires=Thu, 24 Nov 2022 07:39:27 GMT; Path=/ Set-Cookie: AWSALBCORS=NwSlIprdUM9DuDngcfYNsWXnH41AGiHSNRmxgqXAt/brpofXK2+Mz+ia9 AekK/DRy1A7f0DBNY7EI+xGb94Mps9NORNNbY40Ox7PAcjA5Wacp3H1lMcoFu6pBb59; Expires=Thu , 24 Nov 2022 07:39:27 GMT; Path=/; SameSite=None; Secure CF-Cache-Status: DYNAMIC Strict-Transport-Security: max-age=0; includeSubDomains; preload Server: cloudflare CF-RAY: 76b6d0060f889438-SJC Socket Connected and subscribed {"topic": "collection:","eve nt": "phx_join","payload": {},"ref": 0} after receive():{"event":"phx_reply","pa yload":{"response":{},"status":"ok"},"ref":0,"topic":"collection:"} [2022-11-17 16:46:25] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WscMain.phpLINE:340CODE:111Message:Empty read; connect ion dead? Stream state: {"crypto":{"protocol":"UNKNOWN","cipher_name":"TLSAES 256_GCM_SHA384","cipher_bits":256,"cipher_version":"TLSv1.3"},"timed_out":false, "blocked":true,"eof":true,"stream_type":"tcp_socket/ssl","mode":"r+","unreadby tes":0,"seekable":false} [2022-11-17 16:46:25] local.ERROR: catch connection dead or invalid upgrade:Empt y read; connection dead? Stream state: {"crypto":{"protocol":"UNKNOWN","cipher name":"TLS_AES_256_GCM_SHA384","cipher_bits":256,"cipher_version":"TLSv1.3"},"ti med_out":false,"blocked":true,"eof":true,"stream_type":"tcp_socket/ssl","mode": "r+","unread_bytes":0,"seekable":false} [2022-11-17 16:46:28] local.ERROR: closing socket: Empty read; connection dead? Stream state: {"crypto":{"protocol":"UNKNOWN","cipher_name":"TLS_AES_256_GCM_SH A384","cipher_bits":256,"cipher_version":"TLSv1.3"},"timed_out":false,"blocked": true,"eof":true,"stream_type":"tcp_socket/ssl","mode":"r+","unread_bytes":0,"se ekable":false} [2022-11-17 16:46:28] local.INFO: Empty read; connection dead? Stream state: {" crypto":{"protocol":"UNKNOWN","cipher_name":"TLS_AES_256_GCM_SHA384","cipher_bit s":256,"cipher_version":"TLSv1.3"},"timed_out":false,"blocked":true,"eof":true," stream_type":"tcp_socket/ssl","mode":"r+","unread_bytes":0,"seekable":false} Socket Connected and subscribed {"topic": "collection:","event": "phx_join","payload": {}," ref": 0} 订阅后receive():{"event":"phx_reply","payload":{"response":{},"status": "ok"},"ref":0,"topic":"collection:"} [2022-11-17 17:45:14] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WscMain.phpLINE:340CODE:111Message:Empty read; connect ion dead? Stream state: {"crypto":{"protocol":"UNKNOWN","cipher_name":"TLSAES 256_GCM_SHA384","cipher_bits":256,"cipher_version":"TLSv1.3"},"timed_out":false, "blocked":true,"eof":true,"stream_type":"tcp_socket/ssl","mode":"r+","unreadby tes":0,"seekable":false} [2022-11-17 17:45:14] local.ERROR: catch connection dead or invalid upgrade:Empt y read; connection dead? Stream state: {"crypto":{"protocol":"UNKNOWN","cipher name":"TLS_AES_256_GCM_SHA384","cipher_bits":256,"cipher_version":"TLSv1.3"},"ti med_out":false,"blocked":true,"eof":true,"stream_type":"tcp_socket/ssl","mode": "r+","unread_bytes":0,"seekable":false} [2022-11-17 17:45:17] local.ERROR: closing socket: Empty read; connection dead? Stream state: {"crypto":{"protocol":"UNKNOWN","cipher_name":"TLS_AES_256_GCM_SH A384","cipher_bits":256,"cipher_version":"TLSv1.3"},"timed_out":false,"blocked": true,"eof":true,"stream_type":"tcp_socket/ssl","mode":"r+","unread_bytes":0,"se ekable":false} [2022-11-17 17:45:18] local.INFO: Empty read; connection dead? Stream state: {" crypto":{"protocol":"UNKNOWN","cipher_name":"TLS_AES_256_GCM_SHA384","cipher_bit s":256,"cipher_version":"TLSv1.3"},"timed_out":false,"blocked":true,"eof":true," stream_type":"tcp_socket/ssl","mode":"r+","unread_bytes":0,"seekable":false} Socket Connected and subscribed {"topic": "collection:","event": "phx_join","payload": {}," ref": 0} 订阅后receive():{"event":"phx_reply","payload":{"response":{},"status": "ok"},"ref":0,"topic":"collection:"} [2022-11-17 18:54:40] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WscMain.phpLINE:340CODE:111Message:Empty read; connect ion dead? Stream state: {"crypto":{"protocol":"UNKNOWN","cipher_name":"TLSAES 256_GCM_SHA384","cipher_bits":256,"cipher_version":"TLSv1.3"},"timed_out":false, "blocked":true,"eof":true,"stream_type":"tcp_socket/ssl","mode":"r+","unread_by tes":0,"seekable":false}

[2022-11-17 20:35:32] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WscMain.phpLINE:340CODE:111Message:Empty read; connect ion dead? Stream state: {"crypto":{"protocol":"UNKNOWN","cipher_name":"TLSAES 256_GCM_SHA384","cipher_bits":256,"cipher_version":"TLSv1.3"},"timed_out":false, "blocked":true,"eof":true,"stream_type":"tcp_socket/ssl","mode":"r+","unreadby tes":0,"seekable":false} [2022-11-17 20:35:32] local.ERROR: catch connection dead or invalid upgrade:Empt y read; connection dead? Stream state: {"crypto":{"protocol":"UNKNOWN","cipher name":"TLS_AES_256_GCM_SHA384","cipher_bits":256,"cipher_version":"TLSv1.3"},"ti med_out":false,"blocked":true,"eof":true,"stream_type":"tcp_socket/ssl","mode": "r+","unread_bytes":0,"seekable":false} [2022-11-17 20:35:35] local.ERROR: closing socket: Empty read; connection dead? Stream state: {"crypto":{"protocol":"UNKNOWN","cipher_name":"TLS_AES_256_GCM_SH A384","cipher_bits":256,"cipher_version":"TLSv1.3"},"timed_out":false,"blocked": true,"eof":true,"stream_type":"tcp_socket/ssl","mode":"r+","unread_bytes":0,"se ekable":false} [2022-11-17 20:35:36] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WSClientTrait.phpLINE:136CODE:108Message:Bad opcode in websocket frame: 21 [2022-11-17 20:35:36] local.ERROR: closing socket: Bad opcode in websocket frame : 21 [2022-11-17 20:35:36] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WSClientTrait.phpLINE:136CODE:108Message:Bad opcode in websocket frame: 23 [2022-11-17 20:35:36] local.ERROR: closing socket: Bad opcode in websocket frame : 23 [2022-11-17 20:35:37] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WSClientTrait.phpLINE:136CODE:108Message:Bad opcode in websocket frame: 27 [2022-11-17 20:35:37] local.ERROR: closing socket: Bad opcode in websocket frame : 27 [2022-11-17 20:35:37] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WSClientTrait.phpLINE:136CODE:108Message:Bad opcode in websocket frame: 4 [2022-11-17 20:35:37] local.ERROR: closing socket: Bad opcode in websocket frame : 4 [2022-11-17 20:35:37] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WSClientTrait.phpLINE:136CODE:108Message:Bad opcode in websocket frame: 6 [2022-11-17 20:35:37] local.ERROR: closing socket: Bad opcode in websocket frame : 6 [2022-11-17 20:35:38] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WSClientTrait.phpLINE:136CODE:108Message:Bad opcode in websocket frame: 17 [2022-11-17 20:35:38] local.ERROR: closing socket: Bad opcode in websocket frame : 17 [2022-11-17 20:35:38] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WSClientTrait.phpLINE:136CODE:108Message:Bad opcode in websocket frame: 20 [2022-11-17 20:35:38] local.ERROR: closing socket: Bad opcode in websocket frame : 20 [2022-11-17 20:35:38] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WSClientTrait.phpLINE:136CODE:108Message:Bad opcode in websocket frame: 22 [2022-11-17 20:35:38] local.ERROR: closing socket: Bad opcode in websocket frame : 22 [2022-11-17 20:35:39] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WSClientTrait.phpLINE:136CODE:108Message:Bad opcode in websocket frame: 25 [2022-11-17 20:35:39] local.ERROR: closing socket: Bad opcode in websocket frame : 25 [2022-11-17 20:35:39] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WSClientTrait.phpLINE:136CODE:108Message:Bad opcode in websocket frame: 19 [2022-11-17 20:35:39] local.ERROR: closing socket: Bad opcode in websocket frame : 19 [2022-11-22 15:55:19] local.ERROR: FILE:/web/webdata/dripster/vendor/arthurkushm an/php-wss/src/Components/WscMain.phpLINE:69CODE:104Message:Could not open socke t to "stream.openseabeta.com:443": (0).

eusonlito commented 1 year ago

The log includes a HTTP/1.1 504 Gateway Time-out, are you sure the remote server is running?