mock-webserver: Php 8.2 upgrade has caused an error

I have been using this library with php version 8.0 for a while. And when I decided to upgrade the php version to 8.2 my end to end tests are now failing with the following error:

                                                                                                                        
[donatj\MockWebServer\Exceptions\ServerException] Failed to start server. Is something already running on port 5500?  
                                                                                                                        
#1  /var/www/vendor/donatj/mock-webserver/src/MockWebServer.php:85

I tried to debug the code to check if the server was running actually, It was not!

While debugging, I tried to dump $this->isRunning() in File /donatj/mock-webserver/src/MockWebServer.php:

dump($this->isRunning());
for( $i = 0; $i <= 20; $i++ ) {
	usleep(100000);
	$open = @fsockopen($this->host, $this->port);
	if( is_resource($open) ) {
		fclose($open);
		break;
	}
}
dump($this->isRunning());

This was actually returning false on the first dump and true on the second!!

Do you know how is that related to the php upgrade, and how we can solve that?

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

@mhmdmousawi I am going to close this. If you ever circle back though I’d be curious to know if this fix resolved your issue.