saintsad / phpwebsocket

Automatically exported from code.google.com/p/phpwebsocket
0 stars 0 forks source link

PHP Warning: socket_select(): 9 is not a valid Socket resource #33

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. sudo php -q server.php
2. 192.168.1.15/client.html
3. refresh chrome explorer some times

What is the expected output? What do you see instead?
Stay connected to the chat.
Some times it disconnects from the chat, and on the server side it shows 
messages
PHP Warning:  socket_select(): 6 is not a valid Socket resource in 
/var/www/websocket/server.php on line 15
PHP Warning:  socket_select(): 7 is not a valid Socket resource in 
/var/www/websocket/server.php on line 15
PHP Warning:  socket_select(): 8 is not a valid Socket resource in 
/var/www/websocket/server.php on line 15
PHP Warning:  socket_select(): 11 is not a valid Socket resource in 
/var/www/websocket/server.php on line 15

What version of the product are you using? On what operating system?
Downloadad client.php and server.php from project home 13th June
Server side Ubuntu 11 + Apache2 + PHP5
Client side Windows XP SP3 + Chrome 12

Please provide any additional information below.
I haven't checked the code yet, as it's my first time working with sockets.

Original issue reported on code.google.com by jgom...@gmail.com on 15 Jun 2011 at 10:37

GoogleCodeExporter commented 9 years ago
with these changes the application was running.

-$master=WebSocket("localhost",12345);
+$master=WebSocket("0.0.0.0",12345);

-if ($spaces1 == 0 || $spaces2 == 0 || $numkey1 % $spaces1 != 0 || $numkey2 % 
$spaces2 != 0) {
+if ($spaces1 == 0 || $spaces2 == 0 || fmod($numkey1, $spaces1) != 0 || 
fmod($numkey2, $spaces2) != 0) {

-$r=$h=$o=null;
+$r=$h=$o=$key1=$key2=$data=null; 

only strange action on disconect, I will check the code for my own application.

Original comment by jgom...@gmail.com on 20 Jun 2011 at 9:28

GoogleCodeExporter commented 9 years ago
yes! work!

Original comment by flyin...@gmail.com on 18 Jul 2011 at 7:08

GoogleCodeExporter commented 9 years ago
Super! Now the client connects always!!

Original comment by emaille...@gmail.com on 22 Jul 2011 at 1:26

GoogleCodeExporter commented 9 years ago
I've the same problem since yesterday, my sysadmin mada a major update of the 
centos server and now my phpwebsocket server is not running.

PHP Warning:  socket_select(): 6 is not a valid Socket resource in 
/var/www/websocket/server.php on line 15

I made all the changes suggested and still doesn't work.

Any idea?

Original comment by capon...@gmail.com on 20 Sep 2011 at 7:15

GoogleCodeExporter commented 9 years ago
Strange behaviour:

I am testing completely on localhost but on two PCs
both: WindowsXP,SP3 - nginx1.0, php5.3.3, chrome14
One works always, one doesn't - all the time. I am
confused now.

Original comment by ingob...@googlemail.com on 20 Sep 2011 at 9:44

GoogleCodeExporter commented 9 years ago
Sorry if I confused you also: each of my environments 
are chromebrowser and server nginx+php in each case on
one machine. One server-client-windows works always, the
other never. All files/setups etc are cloned (via dropbox)
and therefore are similar. I can't find a significant 
difference.. but I will tell you, if I find it..

Original comment by ingob...@googlemail.com on 20 Sep 2011 at 10:59

GoogleCodeExporter commented 9 years ago
I see that the now, the websocket headers are like this:

GET / HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: www.xxxxxx.com:12345
Sec-WebSocket-Origin: http://www.xxxxxxxxx.com
Sec-WebSocket-Key: kYuC/SdNC0WoNCLLTm/sZA==
Sec-WebSocket-Version: 8

Only one key, no more key1 and key2.

How I do the handshake?

Original comment by capon...@gmail.com on 20 Sep 2011 at 9:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Additional from me: The difference between my two 
setups (see above) is Chrome13 on  the working PC
and Chrome14 on the never working one. I upgraded
to Chrome14  on the first setup and now  both are
never working.. 

So I googled that Chrome14 (and15) implements the
"ietf-hybi-10" spec  and  Chrome13 is using  some
older spec.  I think the handshake is now working
some different.. (?)

Original comment by ingob...@googlemail.com on 21 Sep 2011 at 10:34

GoogleCodeExporter commented 9 years ago
I'm running on XAMPP 1.7.1 on Windows 7.
I did all the changes mentioned above, in my file "server.php"
But the error is still recurring. Help, please!

Original comment by sankalp....@gmail.com on 11 Oct 2011 at 9:12

GoogleCodeExporter commented 9 years ago
Well the quick answer is available but spread in this project home. The HTTP 
connection string slightly changed and Google Chrome changed this AFAIK in 
version 14 as well. Therefore all (well almost all) examples concerning 
WebSockets are no longer working. Comment 4 in Issue 35 is providing the new 
version of the HTTP protocol as well a possible implementation of the newly 
introduced sub-protocol.

Issue Details:
http://code.google.com/p/phpwebsocket/issues/detail?id=35#c4

The new protocol / sub-protocol explained in the current draft:
http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17#section-5

Original comment by andi.me...@gmail.com on 12 Oct 2011 at 7:01

GoogleCodeExporter commented 9 years ago
This is my first experience with web sockets, Whenever i point my browser to 
client.php, it prints this message in chatbox

WebSocket - status 0
Disconnected - status 3

And on command line, getting these errors,

Notice: Undefined variable: key1 in D:\xampp\htdocs\socket\server.php on line 
143
Notice: Undefined variable: key2 in D:\xampp\htdocs\socket\server.php on line 
143
Warning: socket_select(): 5 is not valid Socket resource in 
D:\xampp\htdocs\socket\server.php on line 15

I am using windows with xampp PHP 5.3.8 on both client and server side
and facing these errors.
Please help 

Original comment by brainsto...@gmail.com on 2 Apr 2012 at 2:53

GoogleCodeExporter commented 9 years ago
I am experiencing the same ... as above. 

erver Started : 2012-05-27 12:59:53
Master socket  : Resource id #4
Listening on   : localhost port 12345

Notice: Undefined variable: key1 in /Library/WebServer/Documents/server.php on 
line 143
Notice: Undefined variable: key2 in /Library/WebServer/Documents/server.php on 
line 143

I understand the issue, does anyone have a resolution?

Original comment by Jesse.Cr...@gmail.com on 27 May 2012 at 6:05

GoogleCodeExporter commented 9 years ago
I am running PHP 5.4.1 on Windows 7 64bit.
I downloaded the code as it is now and ran this in command line from the 
phpwebsocket folder:
php server.php
This is what I get:
Server Started : 2012-05-29 15:30:37
Master socket  : Resource id #4
Listening on   : localhost port 12345

PHP Strict Standards:  Only variables should be passed by reference in C:\Users\
mike_2\Desktop\webhome\phpwebsocket\server.php on line 15

Then I open the client in Chrome 19.0.1084.52
I get this in the browser:
WebSocket - status 0
Disconnected - status 3

In the command line I see:
Notice: Undefined variable: key1 in C:\Users\mike_2\Desktop\webhome\phpwebsocket
\server.php on line 143
PHP Notice:  Undefined variable: key2 in C:\Users\mike_2\Desktop\webhome\phpwebs
ocket\server.php on line 143
PHP Strict Standards:  Only variables should be passed by reference in C:\Users\
mike_2\Desktop\webhome\phpwebsocket\server.php on line 15
Warning: socket_select(): 5 is not a valid Socket resource in C:\Users\mike_2\De
sktop\webhome\phpwebsocket\server.php on line 15

What can we do to fix this. Is it an updated php problem?

Original comment by stokesc...@gmail.com on 29 May 2012 at 9:36

GoogleCodeExporter commented 9 years ago
I am running PHP 5.3.9 on Windows xp
I downloaded the code as it is now and ran this in command line from the 
phpwebsocket folder:
php server.php
This is what I get:
Server Started : 2012-05-29 15:30:37
Master socket  : Resource id #4
Listening on   : localhost port 12345

Then I open the client in Chrome 19.0.1084.52
I get this in the browser:
WebSocket - status 0
Disconnected - status 3

In the command line I see:

Warning: socket_select(): 5 is not a valid Socket resource in C:\Users\mike_2\De
sktop\webhome\phpwebsocket\server.php on line 15

What can we do to fix this. Is it an updated php problem?

Original comment by chandroo...@gmail.com on 30 May 2012 at 12:15

GoogleCodeExporter commented 9 years ago
Same issue here. I tried with the suggested solution posted by on comment #1 
but the problem did  persist.

Any known reason for this?

Original comment by javier.galvez.guerrero on 28 Jun 2012 at 7:32

GoogleCodeExporter commented 9 years ago
idem
Notice: Undefined variable: key1 in D:\mywamp\wamp\www\websocket\server.php on 
line 144
etc...

actually lastest browsers use only 1 key.
Request:
GET /websocket/server.php HTTP/1.1
Host: localhost:12345
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive, Upgrade
Sec-WebSocket-Version: 13
Origin: http://localhost
Sec-WebSocket-Key: WEdh0Gy0k5z39/VfN9lvFQ==
Cookie: __utma=111872281.1222847165.1325647875.1325647875.1325647875.1; 
__utmz=111872281.1325647875.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); 
PHPSESSID=niv88e5dbmnvc0ogvjcusufb44
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket

There is an 'Update' linked at comment 11.
But there others errors when launching 'demo.php':
Deprecated: Call-time pass-by-reference has been deprecated in 
D:\wamp\www\websocket\server\websocket.class.php on line 241
Server Started : 2012-06-28 21:21:33
Listening on   : 0 port 12345
Master socket  : Resource id #10

Fatal error: Class 'Uri1ResourceHandler' not found in 
D:\wamp\www\websocket\demo.php on line 12.

thanks.

Original comment by gillesb...@gmail.com on 28 Jun 2012 at 9:23

GoogleCodeExporter commented 9 years ago
Apparently upon debugging I found that whenever I get "Warning: 
socket_select(): 5 is not a valid Socket resource" error, the number that is 
printed out is the resource id of the socket.  Maybe the socket_accept is not 
creating a valid socket resource?

Original comment by JasonNov...@gmail.com on 21 Jul 2012 at 1:52

GoogleCodeExporter commented 9 years ago
Same for me.
Any solution ?

Original comment by heitz.pa...@gmail.com on 28 Jul 2012 at 7:53

GoogleCodeExporter commented 9 years ago
PHP Notice:  Undefined variable: key1 in /var/www/game/server.php on line 142
PHP Notice:  Undefined variable: key2 in /var/www/game/server.php on line 142
PHP Warning:  socket_select(): 5 is not a valid Socket resource in 
/var/www/game/server.php on line 14

how can i solve it?

Original comment by ToBaiLi...@gmail.com on 10 Nov 2012 at 8:04

GoogleCodeExporter commented 9 years ago
Any solutions for the "...is not a valid Socket resource in..." "...on line 
15..." ?  I am not quite sure what needs to be changed in order for the demo to 
work out of the box.

Original comment by Colby.Ca...@gmail.com on 12 May 2013 at 5:51

GoogleCodeExporter commented 9 years ago
Same here: PHP Warning:  socket_select(): 5 is not a valid Socket resource in 
/var/www/websocket/server.php on line 15

Anybody found a cure?

Original comment by kdob...@gmail.com on 24 Jul 2013 at 3:18

GoogleCodeExporter commented 9 years ago
I also got these problems but with the changes it worked fine on localhost. 
Only if I want to access the script with my other computer it appears again in 
console and I get "disconnected - status 3". Can't find any reason/solution...

Original comment by luucs...@gmail.com on 3 Jul 2014 at 1:24

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Had the same error and got a connection with this solution:

Just use the attched server.php.

Source:
http://phpforum.de/forum/showpost.php?p=1502477&postcount=13

Original comment by thj...@gmail.com on 11 Sep 2014 at 2:47

Attachments:

GoogleCodeExporter commented 9 years ago
thanks the server.php from #26,i run it on my platform

Original comment by wanchang...@gmail.com on 31 Mar 2015 at 3:05

GoogleCodeExporter commented 9 years ago
Got the server running and it works but it does give me an error I'm curious 
about: 

Strict Standards: Only variables should be passed by reference in C:\xampp\htdoc
s\test\server.php on line 15

Original comment by Bradley....@gmail.com on 22 Apr 2015 at 2:08

GoogleCodeExporter commented 9 years ago
@Bradley....@gmail.com

>>    $write       =    NULL;
>>    $exceptions  =    NULL;
>>    socket_select($changed,  $write,  $exceptions,  NULL);

Original comment by DS.Emeri...@gmail.com on 11 May 2015 at 10:13