Abhishek
Abhishek

Reputation: 783

PHP: Maintain a persistent connection to an XMPP chat client

I'm creating a basic chat client using XMPPHP. The other chat client for now is Spark (only for test purposes). I don't understand why does the connect() functioon in XMLStream.php have a timeout of only 30 secs.

1) Is it customizable ?

2) What if I wish to maintain a persistent connection without timing out i.e. without getting idle or disconnected ?

Upvotes: 0

Views: 503

Answers (1)

Varun Bhatia
Varun Bhatia

Reputation: 11

the timeout of 30 seconds would happen if you invoke the PHP script via browser. That's the max time a browser waits for page to load.

In order to bypass it, you need to tell the server to wait more time for page to load. use set_time_limit(X); at the beginning of your PHP script , where X is the amount of time you want the script to keep running.

X=0 means infinity ( not recommended).

You can also run the PHP script via command line where the time limit will not apply.

Upvotes: 1

Related Questions