xenog 0 Posted February 12 I have an unusual requirement and wonder if it's possible with ICS. I have an embedded device that can serve web pages using HTTP. The device is usually installed on a private network, so I cannot access it over the Internet. The device has the means to make a socket connection to any port, so it can escape the private network and firewalls. I use a TSslWSocket to listen for a connection from the device and then manually send an HTTP GET command to the device and wait for the reply. There's no SSL involved. This works well for simple GET commands, but I'd like to do more. Is it possible to pass the socket from TSslWSocket to a component like THttpCli? It would be nice to find a way to have a browser in my app talk to the device. Thanks in advance for your help. Richard Share this post Link to post
Angus Robertson 574 Posted February 12 If you are listening for a connection on port 80, that is a web server, not sure why you then respond with a web command. Or is the embedded device trying to connect to a proxy server? ICS has a proxy component, also TSimpleWebServer and TIcsIpStrmLog that will listen for connections. But none will pass a connection to THttpCli. Angus Share this post Link to post
xenog 0 Posted February 12 Hi Angus, Thanks for your reply. The device is not making an HTTP connection to my server. It is simply opening a socket and sending zero bytes. This can be on any port (not usually 80). I don't need to acknowledge with 200 OK or any other message. Once the device has made the connection to my server, I can then send a message back to the device. If I make an HTTP GET message and send it using TSslWSocket SendStr the device will reply with 200 OK and the page I asked for. I know it's a very strange way to do something, but it's also a clever way to access a device's web page when the device is behind NAT and firewalls. Thanks for your help. Richard Share this post Link to post
Angus Robertson 574 Posted February 12 It would be possible to assign a socket to THttpCli and then call SocketSessionConnected that triggers the first request, perhaps in a descended component. But testing it without your clever device would be painful, it would need a modified web server that made the original connection instead of accepting it, which is where we cross over into proxies. Angus Share this post Link to post
xenog 0 Posted February 12 I can try to make a class that inherits from THttpCli. This should allow me change the protected member FCtrlSocket and then call SocketSessionConnected. Should I FreeAndNil(FCtrlSocket) before I assign the new socket to the device? My Pascal is not good (C++ usually). Thanks for indulging me with this unusual request. It's a shame more devices don't do this and then you could play too 🙂 Cheers, Richard Share this post Link to post
Angus Robertson 574 Posted February 13 The ICS components are event driven, so have various state variables for control, they will need careful manipulation if opening a connection is skipped. Basically, test, fix, repeat. Angus 1 Share this post Link to post
Kas Ob. 121 Posted February 13 Hi, 16 hours ago, xenog said: Is it possible to pass the socket from TSslWSocket to a component like THttpCli? Angus answered, but i want to suggest different and shorter approach. Just build an application with two servers HTTP at port 80 and HTTPS at port 443, make it relay everything from one connection to the other, that should solve your need for browsers secure connection to the device. By relay i mean, there should be one connection for each of these servers and whenever data being received from one then send it to the other one. Share this post Link to post