Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sometimes connection refused, but ends in fatal error #190

Open
kruegge82 opened this issue Nov 18, 2023 · 1 comment
Open

sometimes connection refused, but ends in fatal error #190

kruegge82 opened this issue Nov 18, 2023 · 1 comment
Labels

Comments

@kruegge82
Copy link

Describe the bug
one call it works, next call not... i searched for a reason but cannot find.
Its the check function if connection exists.
Should it end in an fatal error if connection really refused?

Error Log
PHP Fatal error: Uncaught ErrorException: stream_socket_client(): Unable to connect to tcp://xxx.xx.xxx.xx:18804 (Connection refused) in /www/htdocs/w01/domain.com/vendor/textalk/websocket/lib/Client.php:350
Stack trace:
#0 [internal function]: Phrity\Util\ErrorHandler->Phrity\Util{closure}(2, 'stream_socket_c...', '/www/htdocs/w01...', 350)
#1 /www/htdocs/w01/domain.com/vendor/textalk/websocket/lib/Client.php(350): stream_socket_client('tcp://xxx.xx.xx...', 0, '', 5, 4, Resource id #57)
#2 /www/htdocs/w01/domain.com/vendor/phrity/util-errorhandler/src/Phrity/Util/ErrorHandler.php(60): WebSocket\Client->WebSocket{closure}()
#3 /www/htdocs/w01/domain.com/vendor/textalk/websocket/lib/Client.php(347): Phrity\Util\ErrorHandler->with(Object(Closure))
#4 /www/htdocs/w01/domain.com/vendor/textalk/websocket/lib/Client.php(169): WebSocket\Client->connect()
#5 /www/htdocs/w01/domain.com/cron/class.import.php(903): WebSocket\Client->send('{"type":"LABEL"...')
#6 /www/htdocs/w01/domain.com/includes/create_label.php(794): labelprint('files/dhl_label...', '18804')
#7 /www/htdocs/w01/domain.com/picklist_save.php(355): create_dhl_label(Array, Array, Array, 0.488, true, false)
#8 {main}

Next WebSocket\ConnectionException: Could not open socket to "xxx.xx.xxx.xx:18804": stream_socket_client(): Unable to connect to tcp://xxx.xx.xxx.xx:18804 (Connection refused) (0). in /www/htdocs/w01/picker.sendagents.com/vendor/textalk/websocket/lib/Client.php:365
Stack trace:
#0 /www/htdocs/w01/domain.com/vendor/textalk/websocket/lib/Client.php(169): WebSocket\Client->connect()
#1 /www/htdocs/w01/domain.com/cron/class.import.php(903): WebSocket\Client->send('{"type":"LABEL"...')
#2 /www/htdocs/w01/domain.com/includes/create_label.php(794): labelprint('files/dhl_label...', '18804')
#3 /www/htdocs/w01/domain.com/picklist_save.php(355): create_dhl_label(Array, Array, Array, 0.488, true, false)
#4 {main}
thrown in /www/htdocs/w01/domain.com/vendor/textalk/websocket/lib/Client.php on line 365

Versions

  • Version of this library: 1.6.3
  • PHP version: 8.2.9
@kruegge82 kruegge82 added the bug label Nov 18, 2023
@sirn-se
Copy link
Contributor

sirn-se commented Nov 20, 2023

If the server randomly refuses connections, it's most likely a limitation on the server side.

You should wrap send/receive calls in a try/catch clause to handle various errors that might occur.

Please also note that this repo is now maintained as phrity/websocket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants