You are not logged in.
Pages: 1
Is it possible?
I've implemented a callback method using TSQLHttpServer and Websockets but as I can tell from my tests and the code, the TSQLHttpClientWebsockets uses a TCrtSocket derived class which does not allow proxy configuration.
I tried to set the proxy in WinHTTP using
netsh winhttp import proxy source=ie
but this class is not using it.
Can I use a proxy server with the TSQLHttpClientWebsockets class?
Offline
You would not be able to use WebSockets on most HTTP proxies, I'm afraid.
See http://www.infoq.com/articles/Web-Sockets-Proxy-Servers
It will depend on the proxy used at corporate level.
It is not a limitation of TCrtSocket, but of the proxy itself, which does not support WebSockets.
Only less efficient, but more compatible long polling may be compatible with a proxy.
Long polling is planned, but not yet implemented.
See http://synopse.info/forum/viewtopic.php?id=3060
Offline
ab, thanks, but in my tests the TCrtSocket is not even trying to use the proxy, it is trying to make a direct connection.
I opened a proxy server on my host and configured it on a VM, other http requests pass by the proxy server, but the TCrtSocket tries to open a direct connection, is it expected?
Offline
The current version of TCrtSocket does not handle a proxy connection, you are right.
Using the default HTTP client - not the WebSockets version - would use the proxy.
Any input is welcome.
Offline
ab, so there is no way to use Websockets with proxy at this time, right?
Offline
I'd say it depends on the configuration and what somebody understands as a "proxy". When I use apache as a "proxy" and mORMot as it is, then Websockets works as expected.
Offline
Ok, what about a Browser that talks about a (real) proxy (squid) with my mORMot (I mean over websockets)?
Offline
Exactly, the problem is a corporate proxy not reverse proxy.
Offline
It is not a limitation of TCrtSocket, but of the proxy itself, which does not support WebSockets.
Browser-->squid-->apache-->mORMot? That works for me.
@fabioxgn
If it's not limitation of TCrtSocket, than something must be wrong with the proxy (or your configuration).
Last edited by danielkuettner (2015-12-14 20:25:19)
Offline
@ab
The way is the same: Chrome->squid->mORMot
What is the corporate proxy? Is squid a corporate proxy?
Ok, now I understand: the corporate proxy, is a proxy in the company, that blocks the websockets.
I thought, it were a question of "is it possible to use websockets over a proxy?".
Last edited by danielkuettner (2015-12-14 21:22:13)
Offline
Something is confusing me here:
If I use a js client (192.168.1.249) and create a websocket with ws://192.168.16/ to my mORMot
with my "corporate" proxy (192.168.1.10) than RemoteIP in THttpServerSocket.IntiRequest is 192.168.1.10.
That means, websocket traffic and "corporate" proxy is working, or am I wrong?
But if I test with Project31ChatClient than RemoteIP in THttpServerSocket.IntiRequest is 192.168.1.249. Why is TSQLHttpClientWinSock not using the Windows system proxy settings?
I ask just to better understand the things.
Offline
But why it works with ajax?
Offline
Sometimes the words I use are not correct, I'm sorry. With ajax I meant just a simple javascript websocket like this: ws = new WebSocket("ws://192.168.1.16:8888/", "");
I can't believe that here are long polling will be used.
Now after testing a little bit I want to share my experiences:
ws = new WebSocket("ws://192.168.1.16:8888/", "") works with SimpleEchoServer over a forward (forward is more precise than corporate) proxy.
Than I've played with/in mORMotHttpclient.pas
constructor TSQLHttpClientGeneric.Create(const aServer, aPort: AnsiString;
aModel: TSQLModel; SendTimeout,ReceiveTimeout,ConnectTimeout: DWORD);
begin
inherited Create(aModel);
fServer := aServer;
fPort := aPort;
fServer:= '192.168.1.10'; <-- this is the proxy
fPort:= '3128'; <-- this is the proxy port
fKeepAliveMS := 20000; // 20 seconds connection keep alive by default
fCompression := [hcSynLZ]; // may add hcDeflate for AJAX clients
fConnectTimeout := ConnectTimeout;
fSendTimeout := SendTimeout;
fReceiveTimeout := ReceiveTimeout;
end;
and in SynCrtSock.pas
procedure TSQLHttpClientGeneric.InternalURI(var Call: TSQLRestURIParams);
var Head, Content, ContentType: RawUTF8;
P: PUTF8Char;
res: Int64Rec;
begin
{$ifdef WITHLOG}
fLogClass.Enter(self,nil,true);
{$endif}
Head := Call.InHead;
Head:= 'Host: 192.168.1.16:8888'; <-- in case of a proxy the header must have a new line with the (real) target host
...
procedure THttpClientSocket.RequestSendHeader(const url, method: SockString);
var aURL: SockString;
begin
if Sock<0 then
exit;
if SockIn=nil then // done once
CreateSockIn; // use SockIn by default if not already initialized: 2x faster
if TCPPrefix<>'' then
SockSend(TCPPrefix);
if (url='') or (url[1]<>'/') then
aURL := '/'+url else // need valid url according to the HTTP/1.1 RFC
aURL := url;
aURL:= 'http://192.168.1.16:8888/' + url; <-- here the URI of the real server (not proxy) has to be as absolute URI in case of a proxy
SockSend([method,' ',aURL,' HTTP/1.1']);
if Port='80' then
SockSend(['Host: ',Server]) else
SockSend(['Host: ',Server,':',Port]);
SockSend(['Accept: */*'#13#10'User-Agent: ',UserAgent]);
end;
With these small changes the ChatClient connects over the proxy to the ChatServer.
But the Callback doesn't work yet.
Here I'm stuck.
@ab
Neither I need this feature at the moment nor I use a delphi client for my project. I just try to better understand the behavior of http/websockets/proxy internals.
Offline
I've found an interesting post here:
https://blogs.oracle.com/PavelBucek/ent … http_proxy
If the http-client wants to use a proxy, then he has to replace the GET with a CONNECT.
Perhaps would this be working...
Offline
Pages: 1