troubleshooting Question

How do I maintain an open socket to receive TCP strings and generate an HTTP GET from these?

Avatar of belias1
belias1Flag for United States of America asked on
TCP/IPScripting LanguagesNetworking
7 Comments1 Solution612 ViewsLast Modified:
I have two devices that I need to establish communication between (IP Camera --> Automation Controller).  I've made some progress, but I've run into a road-block that I'm looking for some assistance with.  Any help would be greatly appreciated.


1.  IP Camera - Sends a plain text string to 192.168.2.XXX:XXXX; expects this port (socket?) to remain open indefinitely.  When the port is closed, it takes up to 3 minutes for the camera to recognize this (and reconnect) and during this time no communication is transmitted - a big problem.

                        |    transmits to

2.  Automation Controller - Receives commands via HTTP GET interface.  Closes the socket after the GET command is received and really irritates the IP camera.

The Automation Controller can be triggered by opening a browser window and entering:



I have changed the text string that the camera sends to:

GET /rest/programs/0071/runThen HTTP/1.1[CRLF]Authorization: Basic xxxxxxxxxx[CRLF][CRLF]

where [CRLF] = carriage return / line feed (i.e. new line)

This works great the first time.  However, after the command is received the Automation Controller responds with a 200 and closes the connection.


A method to transmit a text string (i.e. "motion detected") to an Automation Controller that doesn't result in a closed socket connection.  This may be a change in the text string format, or a small program that runs on my server PC, etc.

Actually, I don't really care about the specifics - only that the end result is reliable communication from the IP camera to the Automation Controller.    Open to ideas...


After doing a bit of research on my own (and you'll have to excuse my inexperience here), apparently the camera is expecting the server to be a simple TCP server, as opposed to an HTTP server that closes the connection after each GET request.

The camera is simply sending a plain text string to a port.  In this case, the default string from the camera is "motion detected". As an example, if I send this string to PC-based recording software, it accepts the string with no reply and does not close the connection. I confirmed this with telnet - the port remains open indefinitely on the recording software waiting for additional strings. Apparently, this method is fairly standard in the IP camera industry...

Thanks for the help!

- Brian

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros