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

Undefined variable: address #136

Closed
daveherman71 opened this issue Apr 13, 2021 · 2 comments · Fixed by #137
Closed

Undefined variable: address #136

daveherman71 opened this issue Apr 13, 2021 · 2 comments · Fixed by #137
Assignees
Labels

Comments

@daveherman71
Copy link

If you have set a stream context with the persistent constructor option to true then PHP throws the following error:

A PHP Error was encountered

Severity: Notice
Message:  Undefined variable: address
Filename: lib/Client.php
Line Number: 202

At this point $address is not defined because it is set within the if (!$persistent || ftell($this->socket) == 0) { statement starting at line 131 which cannot be reached.

The client was created as follow:

$context = stream_context_create();

stream_context_set_option($context, 'ssl', 'verify_peer', FALSE);
stream_context_set_option($context, 'ssl', 'verify_peer_name', FALSE);

$client = new WebSocket\Client("ws://echo.websocket.org/", array(
	'context' => $context,
	'timeout' => 300
));

A proposed fix would be to move line 202 ($this->logger->info("Client connected to {$address}");) into the if (!$persistent || ftell($this->socket) == 0) { statement.

@sirn-se sirn-se self-assigned this Apr 17, 2021
@sirn-se sirn-se linked a pull request Apr 17, 2021 that will close this issue
@sirn-se
Copy link
Contributor

sirn-se commented Apr 17, 2021

PR to fix this issue is pending; #137

@sirn-se
Copy link
Contributor

sirn-se commented Apr 18, 2021

Included in patch version 1.5.3.

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

Successfully merging a pull request may close this issue.

2 participants