The community forums are in BETA and closed to the public.

How do I keep a TCP Socket Connection Open on my first Network Call

Keeping a TCP Socket Connection Open on your first Network Call

NOTE If you are using PubNub JavaScript, Java or Objective-C SDK, then the SDK will take care of Keeping the TCP Socket Connection open for you automatically after you have subscribed to a data channel.

You can keep a TCP Socket active and alive forever with PubNub's unlimited TTL Socket Session Policy by writing an initial data payload over the socket.

Watch Video Vimeo Video Overview on Keeping a TCP Socket Connection Open on your first Network Call

> telnet pubsub.pubnub.com 80

After you've established the TCP connection, send the following payload:

GET /time/0 HTTP/1.1
Host: pubnub

Don't forget the add the line break carriage returns into the socket write (transmit) buffer like this:

GET /time/0 HTTP/1.1\r\n
Host: pubnub\r\n\r\n

Now the TCP Socket will remain open Forever with PubNub's unlimited TCP Lifetime Policy. Hurray! Give it a try yourself right now.

Receiving Messages - Streaming

To constantly stream messages over PubNub you can issue a ~stream~ API call:

GET /stream/demo/CHANNEL-A/0/1000 HTTP/1.1
Host: pubnub

Sending Messages via Pipeline

If you want to send a message over telnet, you can issue a publish call:

GET /publish/demo/demo/0/CHANNEL-A/0/"Hi" HTTP/1.1
Host: pubnub

GET /publish/demo/demo/0/CHANNEL-A/0/"Hello" HTTP/1.1
Host: pubnub

GET /publish/demo/demo/0/CHANNEL-A/0/"Whatsup" HTTP/1.1
Host: pubnub

Comments to this discussion are now closed!