shuhaib864 / xmpphp

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

Message: fclose(): supplied argument is not a valid stream resource #53

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
the first, i'm sorry for my english

What steps will reproduce the problem?
1. Auth Session.

What is the expected output? What do you see instead?

when, I've tried to entering an invalid password.
If everything was ok i expect no notice buy instead i get:

Message: fclose(): supplied argument is not a valid stream resource
Filename: Xmpphp/XMLStream.php 
Line Number: 403

What version of the product are you using? On what operating system?

I use xmpphp-0.1rc1-r70 On MS-WINDOWS 2003 with PHP5 and apache 2.2.10

Please provide any additional information below.

How to fix the error.

Original issue reported on code.google.com by unavaila...@gmail.com on 11 May 2009 at 9:30

GoogleCodeExporter commented 8 years ago
Same trouble:

<?php
include 'XMPPHP/XMPP.php';
$conn = new XMPPHP_XMPP('talk.google.com', 5222, 'zillah.giovanni', 'blablabla',
'xmpphp', 'gmail.com', $printlog=true, $loglevel=XMPPHP_Log::LEVEL_VERBOSE);
$conn->autoSubscribe();

try {
//    $conn->useEncryption(false);
    $conn->connect();
    $conn->processUntil('session_start');
//    $conn->presence();
//    $conn->processUntil('presence');
//    $conn->getRoster();
    $conn->message('zillah@jabber.ru', 'This is a test message!');
    $conn->disconnect();
} catch(XMPPHP_Exception $e) {
    die($e->getMessage());
}
?>

1251713962 [INFO]: Connecting to tcp://talk.google.com:5222
1251713962 [VERBOSE]: Socket is ready; send it.
1251713962 [VERBOSE]: SENT: <stream:stream to="gmail.com"
xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" 
version="1.0">
1251713962 [VERBOSE]: Successfully sent 114 bytes.
1251713962 [VERBOSE]: RECV: <stream:stream from="gmail.com" 
id="B7A2622EF6F47952"
version="1.0" xmlns:stream="http://etherx.jabber.org/streams"
xmlns="jabber:client"><stream:features><starttls
xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></starttls><mechanisms
xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-GOOGLE-TOKEN</mechanism></
mechanisms></stream:features>
1251713962 [DEBUG]: Calling features_handler
1251713962 [VERBOSE]: Socket is ready; send it.
1251713962 [VERBOSE]: SENT: <starttls
xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>
1251713962 [VERBOSE]: Successfully sent 73 bytes.
1251713962 [VERBOSE]: RECV: <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
1251713962 [DEBUG]: Calling tls_proceed_handler
1251713962 [INFO]: Starting TLS encryption
1251713962 [VERBOSE]: Socket is ready; send it.
1251713962 [VERBOSE]: SENT: <stream:stream to="gmail.com"
xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" 
version="1.0">

1251713962 [VERBOSE]: Successfully sent 114 bytes.
1251713963 [VERBOSE]: RECV: <stream:stream from="gmail.com" 
id="C7B870E5BD81D04F"
version="1.0" xmlns:stream="http://etherx.jabber.org/streams" 
xmlns="jabber:client">
1251713963 [VERBOSE]: RECV: <stream:features><mechanisms
xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>
X-GOOGLE-TOKEN</mechanism></mechanisms></stream:features>
1251713963 [DEBUG]: Calling features_handler
1251713963 [INFO]: Attempting Auth...
1251713963 [VERBOSE]: Socket is ready; send it.
1251713963 [VERBOSE]: SENT: <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
mechanism='PLAIN'>11111111111111111111111111111111111</auth>
1251713963 [VERBOSE]: Successfully sent 108 bytes.
1251713963 [VERBOSE]: RECV: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
1251713963 [DEBUG]: Calling sasl_success_handler
1251713963 [INFO]: Auth success!
1251713963 [VERBOSE]: Socket is ready; send it.
1251713963 [VERBOSE]: SENT: <stream:stream to="gmail.com"
xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" 
version="1.0">
1251713963 [VERBOSE]: Successfully sent 114 bytes.
1251713963 [VERBOSE]: RECV: <stream:stream from="gmail.com" 
id="06375BA3F0289101"
version="1.0" xmlns:stream="http://etherx.jabber.org/streams" 
xmlns="jabber:client">

1251713963 [VERBOSE]: RECV: <stream:features><bind
xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session
xmlns="urn:ietf:params:xml:ns:xmpp-session"/></stream:features>
1251713963 [DEBUG]: Calling features_handler
1251713963 [VERBOSE]: Socket is ready; send it.
1251713963 [VERBOSE]: SENT: <iq xmlns="jabber:client" type="set" id="1"><bind
xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>xmpphp</resource></bind></iq>
1251713963 [VERBOSE]: Successfully sent 130 bytes.
1251713963 [VERBOSE]: RECV: <iq id="1" type="result"><bind
xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>zillah.giovanni@gmail.com/xmpphp0B
5F2F65</jid></bind></iq>
1251713963 [INFO]: Bound to zillah.giovanni@gmail.com/xmpphp0B5F2F65
1251713963 [VERBOSE]: Socket is ready; send it.
1251713963 [VERBOSE]: SENT: <iq xmlns='jabber:client' type='set' id='2'><session
xmlns='urn:ietf:params:xml:ns:xmpp-session' /></iq>
1251713963 [VERBOSE]: Successfully sent 104 bytes.
1251713963 [VERBOSE]: RECV:  
1251713963 [VERBOSE]: RECV: <iq type="result" id="2"/>
1251713963 [INFO]: Session started
1251713963 [DEBUG]: EVENT: session_start
1251713963 [VERBOSE]: Socket is ready; send it.
1251713963 [VERBOSE]: SENT: <message 
from="zillah.giovanni@gmail.com/xmpphp0B5F2F65"
to="zillah@jabber.ru" type='chat'><body>This is a test message!</body></message>

1251713963 [VERBOSE]: Successfully sent 137 bytes.
1251713963 [VERBOSE]: Disconnecting...
1251713963 [VERBOSE]: Socket is ready; send it.
1251713963 [VERBOSE]: SENT: </stream:stream>
1251713963 [VERBOSE]: Successfully sent 16 bytes.
1251713964 [VERBOSE]: Error on stream_select()
<br />
Warning:  fclose() expects parameter 1 to be resource, null given in
C:\xampp\phplibs\XMPPHP\XMLStream.php on line 403<br />
1251713964 [VERBOSE]: Error on stream_select()
<br />

...

Warning:  fclose() expects parameter 1 to be resource, null given in
C:\xampp\phplibs\XMPPHP\XMLStream.php on line 403<br />

1251713964 [VERBOSE]: Error on stream_select()

PS: xmpphp-0.1rc2-r77

Original comment by evgeny.y...@gmail.com on 31 Aug 2009 at 10:25

GoogleCodeExporter commented 8 years ago
hello

i get the same error even when i add the correct password .

any ideas

Original comment by karan26....@gmail.com on 25 Nov 2009 at 3:02

GoogleCodeExporter commented 8 years ago
i get the same problem...

with the example for send a message is working, the message is sended but i get 
the 
error:
Warning: fclose(): supplied argument is not a valid stream resource in 
C:\Program 
Files\VertrigoServ\www\gtalk\XMPPHP\XMLStream.php on line 403

somebody help me please....

Original comment by isantosp...@gmail.com on 27 Nov 2009 at 7:16

GoogleCodeExporter commented 8 years ago
I noted this problem on Windows XP with XAMPP. I found some troubles using PHP 
function stream_select with windows os. Then I copied everything to Linux box 
and 
all went fine.
I also tried to hack the code, but no luck there...

Original comment by nomina.s...@gmail.com on 29 Dec 2009 at 11:29

GoogleCodeExporter commented 8 years ago
It's easy!
I change the code 
if($this->socket)
{
   fclose($this->socket);
   $this->socket = NULL;    
}

Original comment by cente...@gmail.com on 14 Jan 2010 at 3:52

GoogleCodeExporter commented 8 years ago
@centerqi  Where in the XMLStream.php file did you make the change?  there are 
at
least 4-5 occurrences of of fclose($this->socket);

Original comment by WhoBu...@gmail.com on 22 Feb 2010 at 5:56

GoogleCodeExporter commented 8 years ago
I changed line 266 from a split to an explode and that issue didn't occur again.
xmpphp 0.1rc2-r77
PHP 5.3.0
WAMP server 2.0i
-andy

Original comment by badan...@gmail.com on 9 Jun 2010 at 10:15

GoogleCodeExporter commented 8 years ago
Problem still persists in xmpphp 0.1rc2-r77 even if password is right, when 
talking to GoogleTalk.
"Comment 7 by badandye" doesn't help, "Comment 5 by centerqi," solves the 
problem.

Original comment by sysole...@gmail.com on 7 Sep 2010 at 2:45

GoogleCodeExporter commented 8 years ago
Noticed that google talk doesn't seem to send the final </stream:stream> 
response (or it's PHP's fault; not sure).  You'll end up in an endless 
__process() loop if you don't set $this->disconnected to TRUE when you close 
the socket.

$updated = @stream_select($read, $write, $except, $secs, $usecs);
            if ($updated === false) {
                $this->log->log("Error on stream_select()",  XMPPHP_Log::LEVEL_VERBOSE);
                if ($this->reconnect) {
                    $this->doReconnect();
                } else {
                    fclose($this->socket);
                    $this->socket = NULL;
// ADDED THIS LINE
                    $this->disconnected = TRUE;
                    return false;
                }
            }

Original comment by lan...@blitzbazaar.com on 9 Jan 2011 at 9:29

GoogleCodeExporter commented 8 years ago
Oops... one more thing:

The stream_select() error seems to be closing the socket as well, so make sure 
to wrap the "fclose($this->socket)" line with a "if ( !empty($this->socket))" 
equivalent.

-Landon

Original comment by lan...@blitzbazaar.com on 9 Jan 2011 at 9:32

GoogleCodeExporter commented 8 years ago
1341817375 [INFO]: Connecting to tcp://talk.google.com:80 1341817375 [VERBOSE]: 
Socket is ready; send it. 1341817375 [VERBOSE]: SENT: 1341817375 [VERBOSE]: 
Successfully sent 114 bytes. 1341817376 [VERBOSE]: RECV: X-GOOGLE-TOKENX-OAUTH2 
1341817376 [DEBUG]: Calling features_handler 1341817376 [INFO]: Attempting 
Auth... 1341817376 [VERBOSE]: Socket is ready; send it. 1341817376 [VERBOSE]: 
SENT: AHNocmkAZGltZGlt 1341817376 [VERBOSE]: Successfully sent 88 bytes. 
1341817376 [VERBOSE]: RECV: 1341817376 [DEBUG]: Calling sasl_failure_handler 
1341817376 [ERROR]: Auth failed! 1341817376 [VERBOSE]: Disconnecting... 
1341817376 [VERBOSE]: Socket is ready; send it. 1341817376 [VERBOSE]: SENT: 
1341817376 [VERBOSE]: Successfully sent 16 bytes. 1341817376 [VERBOSE]: Error 
on stream_select() 
Warning: fclose() expects parameter 1 to be resource, null given in 
C:\xampp\htdocs\sivra\chat\xmpphp-0.1rc2-r77\XMPPHP\XMLStream.php on line 403
Auth failed!
Any solution for this?

Original comment by leelam.a...@gmail.com on 9 Jul 2012 at 7:10