How to use the public Relay Server in the network which is accessible through HTTP Proxy
The nature of the relay server is simple – you publish it in Internet, so everybody can access it from public networks to use SMP. It hides the internal network, and technically it is located in DMZ. In my case, I had the scenario when I needed to write a small SMP application to do the synchronization using relay server. When I want to access a web page in Internet, I have to use the proxy server (e.g. http://myproxy:8080), and I can easily set up it in the browser. Unfortunately, SMP SDK does not provide a capability to use proxy server during the connection, so I decided to use in a different way.
To implement such behavior, you have to download Apache server and configure it to be a proxy server. I will not describe the entire process, because it is not important. What is important are the lines that I used in the configuration file conf/httpd.conf:
LoadModule proxy_module modules/mod_proxy.so ... ProxyRequests On ProxyRemote * http://myproxy:8080 ProxyPass / http://mobile.reverse.proxy.test.com:5001/ ProxyPassReverse / http://mobile.reverse.proxy.test.com:5001/ ...
For example, when if you use IIS as a proxy server, and you open it in the browser you should see the welcome image:
You should also see this image when you open the URL: http://localhost/
If everything works as I described, the following code should work without any problems!
private const String HOST = "localhost"; // my local proxy, o private const Int32 PORTMBS = 80; ... ConnectionProperties connProps = app.ConnectionProperties; connProps.ServerName = HOST; connProps.PortNumber = PORTMBS; ... app.RegisterApplication(); ...
You can also add additional parameters to the proxy configuration such as timeout or keep-alive. They can be helpful if the synchronization takes some time:
ProxyPass / http://mobile.reverse.proxy.test.com:5001/ KeepAlive=On ... ProxyTimeout 60000
Please remember that I would recommend you to use such approach for development purposes only.