Jump to content

Keesver

Members
  • Content Count

    91
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Keesver

  1. To comment on this question, we are using FMX and Delphi (11.1) to build a Windows/Android/IOS app. We are pretty satisfied with the support, development process and stability of the application. One source/multi platform works very well for us. See this link Lynx X - Apps op Google Play. You are welcome to talk to our developers to share ideas or learn how we do stuff with Delphi 11.1
  2. Keesver

    TIdHTTPProxyServer hangs when used with RemObjects

    Yes, it works OK now. Thanks for taking the time explaining the workings of Http and Indy. I have learned a lot over the past few days. I now have my reverse proxy working. Greetings, Kees
  3. Keesver

    TIdHTTPProxyServer hangs when used with RemObjects

    Remy, thanks for your comments again. I got it working now. After adding extra logging I saw some strange behavior myself. RemObjects is sending 'keep-alive' messages and at some point the connection gets closed immediately after reading the POST request: 127.0.0.1:50782 Recv 8/17/2022 1:38:48 AM: POST http://service.a-dato.net:80/handler.ashx/binmessage HTTP/1.1 Host: service.a-dato.net Keep-Alive: 300 Proxy-Connection: keep-alive User-Agent: Remoting SDK Content-Type: application/octet-stream Content-Length: 17 Accept-Encoding: identity Connection: keep-alive R�R ìF+F„�ò${n¼�� 127.0.0.1:50782 Stat Disconnected. Start call: 6 Port: 50782 Addr: 4437F28 Sent call: 6 Port: 50782 Addr: 4437F28 (See log file, line #190) The log shows that port 50782 gets closed right after retrieving the POST request from the client, still CommandPassThrough is getting called which will then raise the 'Connection closed gracefully' exception. Doing some more testing, I found that the port gets closed here: IdCommandHandlers.pas, line #507 if LCommand.Disconnect then begin AContext.Connection.Disconnect; end; I therefore updated TIdHTTPProxyServer.InitializeCommandHandlers and set Disconnect to False: LCommandHandler := CommandHandlers.Add; LCommandHandler.Command := 'POST'; {do not localize} LCommandHandler.OnCommand := CommandPassThrough; LCommandHandler.ParseParams := True; LCommandHandler.Disconnect := False; // <= Set to False And....it works!! Question: Should the command handler Disconnect? Are there any side effects to this change? Full log file added again. ProxyLog.txt
  4. Keesver

    TIdHTTPProxyServer hangs when used with RemObjects

    I do not know how that should work. Http requires that the remote server closes the connection to signal the call has completed. Forcing a CONNECT keeps the connection alive and breaks the flow between client and server. The client keeps waiting for the disconnect to happen, before completing a call to GET/POST.
  5. Keesver

    TIdHTTPProxyServer hangs when used with RemObjects

    I enabled all exceptions in Delphi and learned that a 'Connection closed gracefully' is raised during the communication, once this exception is raised, the communication hangs. Could it be that TIdHTTPProxyServer is re-using a closed socket? I have attached another log file that seems to prove it does. This logs ends with: Reading call: 10 0.0.0.0:0 Stat Disconnected. To investigate, I logged the address of the IdContext used in each call (inside the logfile shown as 'Start call: 8 Port: 49877 Addr: 3928120'). This shows that the connection used in call 10 was previously used in call 8. Call 8 succeeded, while 10 fails. I tried setting TIdHTTPProxyServe.ReuseSocket to 'rsFalse' but this does not make a difference. Hope this helps someone to understand the issue... ProxyLog.txt
  6. Keesver

    TIdHTTPProxyServer hangs when used with RemObjects

    Hello again, I have done some more testing and added extra logging to the proxy server: TIdTCPClient(LContext.FOutboundClient).Connect; try if Intercept <> nil then (Intercept as TIdServerInterceptLogBase).LogWriteString('Start call: ' + callno.ToString + #13#10); TransferData(LContext, LContext.Connection, LContext.FOutboundClient); Sleep(200); if Intercept <> nil then (Intercept as TIdServerInterceptLogBase).LogWriteString('Sent call: ' + callno.ToString + #13#10); LContext.Headers.Clear; LContext.FOutboundClient.IOHandler.Capture(LContext.Headers, '', False); LContext.FTransferMode := FDefTransferMode; LContext.FTransferSource := tsServer; DoHTTPResponse(LContext); if Intercept <> nil then (Intercept as TIdServerInterceptLogBase).LogWriteString('Reading call: ' + callno.ToString + #13#10); TransferData(LContext, LContext.FOutboundClient, LContext.Connection); if Intercept <> nil then (Intercept as TIdServerInterceptLogBase).LogWriteString('Done call: ' + callno.ToString + #13#10); finally LContext.FOutboundClient.Disconnect; end; I have attached a logfile. In total 10 calls are made by the client. When the call succeeds, there is a message in the logfile saying 'Done: ' + call number. Calls 8 and 9 do not return a result, however call 10 does. Before a call is started there is a message indicating the connection is started (like 127.0.0.1:50376 Stat Connected.), however there are only 9 'Stat Connected' messages for 10 calls. Are connections re-used or does this indicate a problem with TIdHTTPProxyServer? I also tried synchronizing the calls to the server by adding System.TMonitor.Enter(Self)/System.TMonitor.Exit(Self) at the start and end of method CommandPassThrough. This always causes a deadlock. I think this should work. Questions: Is it logical that only 9 connections are started for 10 calls? How can I synchronize all calls to the server? ProxyLog.txt ProxyTest.zip
  7. Keesver

    TIdHTTPProxyServer hangs when used with RemObjects

    Hello Remy, Thanks for taking to time to reply. The log shows that that every request receives a response, except the one highlighted. The log also shows that the first call to the server worked (that is calling LoginService.DomainCheck), trying to call the server a second time (re-using the same RemObjects channel) fails. I will do some more debugging to find out where it fails. Your clarifications are a good start starting points. Greetings
  8. Keesver

    Vcl to Fmx

    I purchased MIDA some time ago, it did what it had to do. Unfortunately it stopped working because the tool contacts a registration server at startup and this server has been down for a long time now (I think more than 2 years). I could never reach the developer/company behind MIDA. There is another tool that can help out though: INNOVA Solutions - Delphi Code Converter - VCL Form to FireMonkey FMX Form Sorry for bringing the bad news.
  9. Keesver

    Chain of two HttpProxyServer servers

    Hello, We want to add remote support to our application and for this we want to use two idHttpProxyServer's chained together. The first server resides on our public server, the second instance resides on the customers network. This is the code we are using: public server: constructor TRemoteServer.Create(IP: string; Port: Integer); begin IdHTTPProxyServer1 := TIdHTTPProxyServer.Create(nil); IdHTTPProxyServer1.ReuseSocket := rsTrue; IdHTTPProxyServer1.DefaultPort := Port; IdHTTPProxyServer1.OnHTTPBeforeCommand := HTTPBeforeCommandHandler; var handler := IdHTTPProxyServer1.CommandHandlers.Add; handler.Command := 'DEST'; handler.HelpSuperScript := 'Sets caller as a DESTINATION for remote support (usage DEST PIN URL)'; handler.OnCommand := DEST_Handler; if (IP <> '') and (Port <> 0) then begin Writeln('Starting server, binding to: ' + IP + '-' + Port.ToString); var bind := IdHTTPProxyServer1.Bindings.Add; bind.IP := IP; bind.Port := Port; bind.ReuseSocket := rsTrue; end else Writeln('Starting server, default binding'); IdHTTPProxyServer1.Active := True; Writeln('Server running, listening on: ' + IdHTTPProxyServer1.Bindings[0].IP + ' - ' + IdHTTPProxyServer1.Bindings[0].Port.ToString); end; procedure TRemoteServer.DEST_Handler(ASender: TIdCommand); begin Writeln(ASender.RawLine); dest_ip := ASender.Context.Binding.PeerIP; dest_port := ASender.Context.Binding.PeerPort; dest_pin := ASender.Params[0]; dest_url := ASender.Params[1]; Writeln('Address: ' + dest_ip + ' - ' + dest_port.ToString); end; procedure TRemoteServer.HTTPBeforeCommandHandler(AContext: TIdHTTPProxyServerContext); begin if dest_ip <> '' then begin Writeln('Command redirected to DESTINATION: ' + dest_ip + ' - ' + dest_port.ToString); var tempIO := TIdIOHandlerStack.Create(AContext.OutboundClient); tempIO.ReuseSocket := rsTrue; // tempIO.BoundIP := '10.0.2.4'; //IdHTTPProxyServer1.Bindings[0].IP; tempIO.BoundPort := 443; // IdHTTPProxyServer1.Bindings[0].Port; var tempProxy := TIdConnectThroughHttpProxy.Create(AContext.OutboundClient); tempProxy.Enabled := True; tempProxy.Host := dest_ip; tempProxy.Port := dest_port; tempIO.TransparentProxy := tempProxy; AContext.OutboundClient.IOHandler := tempIO; end; end; Client code: procedure TForm1.ConnectToRemote(Connection: string); begin HTTPProxyServer.Active := False; IdTCPClient1.Disconnect; IdTCPClient1.Host := <SERVER IP/URL>; //Connection.Split([':'])[0]; IdTCPClient1.Port := <SERVER PORT>; // Connection.Split([':'])[1].ToInteger; IdTCPClient1.Connect; // Tell server we are there IdTCPClient1.SendCmd('DEST 4444 https://abc.com'); HTTPProxyServer.Bindings.Clear; var bind := HTTPProxyServer.Bindings.Add; bind.IP := IdTCPClient1.Socket.Binding.IP; bind.Port := IdTCPClient1.Socket.Binding.Port; bind.ReuseSocket := rsTrue; HTTPProxyServer.Active := True; end; This setup works when we run both server and client on the same computer. However, when we put the server on a remote computer, it does not work. Should this work, or do we need other means to make this happen? Thanks and regards, Kees
  10. Keesver

    Chain of two HttpProxyServer servers

    I have done some more testing and found that my setup fails because the proxy on the server tries to connect to the local proxy from a different port number/connection. This communication is (logically) blocked by the firewall. I thought this code made the server proxy communicate through the same channel as previously established between client and server: var tempIO := TIdIOHandlerStack.Create(AContext.OutboundClient); tempIO.OnBeforeBind := IOHandlerStack_BeforeBind; tempIO.ReuseSocket := rsTrue; tempIO.BoundPort := IdHTTPProxyServer1.Bindings[0].Port; <== Re-use outbound port from server to prevent blocking by firewall I think this cannot work because the server proxy cannot reach the local proxy through the firewall. The connection between the two proxies must be initiated from the "inside". This is what I'm trying to achieve: Remote <x> Server proxy <x> local (reverse) proxy < > Internal network 'x' = firewall 1. local proxy opens connection with Server proxy 2. local proxy sends 'DEST commend' to register itself with Server proxy 3. Remote queries Server proxy for available clients 4. Remote sends 'REMOTE' command to server to to connect to a certain 'DEST' 5. Remote starts HTTP communication with given 'DEST' ==> here it failes because server proxy opens new channel to local proxy Maybe my setup will never work and should I follow a very different path. Hints and tips more than welcome. Greetings
  11. Keesver

    Chain of two HttpProxyServer servers

    Thanks for the tips, I'll try to implement them.
  12. Keesver

    Chain of two HttpProxyServer servers

    Update: It works when I turn off the Firewall on my internet router (one step forward). Apparently there are other ports/channels needed to make a HTTPProxy work? Investigating......
  13. Keesver

    Chain of two HttpProxyServer servers

    There is no error, the call from the remote server back into the client simply does not reach it's destination. The remote server does receive a HTTPBeforeCommand event, this line is being called on the server: Writeln('Command redirected to DESTINATION: ' + dest_ip + ' - ' + dest_port.ToString); The connection between client and server seems to be working. When I use telnet to connect to the server, I do get a response from the server when I execute the 'HELP' command. Similar the call to SendCmd('DEST') in our client returns '200 OK'. Also 'netstat' shows an active connection between client and server. Maybe my question is: what do I need more that an active (TCP) connection between client and server? Does the HTTP Proxy server requires additional channels to be opened to make this work? Or should the single channel suffice?
  14. Keesver

    Interbase Int64 support

    Which data type should be used for Int64 values? I tried Int64 and bigint, both return an error: create table Test(ID Int64) create table Test(ID bigint) Error message: Project IBTest.exe raised exception class EIBNativeException with message '[FireDAC][Phys][IB]Dynamic SQL Error SQL error code = -607 Invalid command Specified domain or source column does not exist'. Thanks
  15. Keesver

    Interbase Int64 support

    ok, will do. I was trying to use FDBatchMove + FDBatchMoveSQLWriter to import a table from MSSql into Interbase. The internal table generator uses 'Int64' for such fields, am I using the wrong generator? Greetings, Kees
  16. According to this document ISO 8601 - Wikipedia Monday 29 December 2008 is written as "2009-W01-1" when a week number is used. As you can see, instead of 2008, the value 2009 is shown. What date formatting function supports this in Delphi? Thanks
  17. Keesver

    ISO8901: Week numbers and year

    WeekOfTheYear is working. I was looking for something like DateTimeToString which supports displaying dates like above using week numbers (aka "2009-W01")
  18. Hello, We are looking at safely handling queued calls. The problem is that under some circumstances the object used inside the queued method is freed before the method gets executed. This raises an exception. Can we use this construct to fix it: type ITest = interface ['{10DD63EA-490E-45D5-9250-72AEB1FF6D19}'] function GetName: string; procedure SetName(const Value: string); end; TTest = class(TInterfacedObject, ITest) protected FName: string; function GetName: string; procedure SetName(const Value: string); end; TObjectWithTest = class private FTest: ITest; public constructor Create(const AInterface: ITest); procedure QueueCallSafe([weak]AInterface: ITest); function GetTest: ITest; end; implementation procedure TObjectWithTest.QueueCallSafe([weak]AInterface: ITest); begin TThread.ForceQueue(nil, procedure begin if AInterface = nil then ShowMessage('nil') else ShowMessage('not nil'); end); end; procedure TForm1.Button3Click(Sender: TObject); begin var obj := TObjectWithTest.Create(TTest.Create); obj.QueueCallSafe(obj.GetTest); // Free object --> [weak] reference will be cleared (no exception!!) obj.Free; end;
  19. Can you explain why supports/queryinterface can't be used?
  20. Keesver

    SmartScreen troubles

    We are using EV (extended validation) code signing certificates to add trust, this should prevent Windows from asking additional confirmation when installing our software. In addition, when the certificate is renewed, trust statistics are kept because the new certificate is recognized as being the same as the 'old' one. Requesting such a certificate requires extra steps during the certification process. (I can send you an installation url if you want to see how this works out)
  21. Keesver

    Android : EGL PBuffer Surface Errcode : 12297

    This seems to be related: 6546 – EglCreateWindowSurface failed with error 12297 (0x3009) (xamarin.github.io)
  22. Keesver

    Learning Delphi

    Hello, We extended our team with new (inexperienced) developers. What would be the best way to teach them Delphi? Greetings, Kees
  23. Keesver

    Learning Delphi

    Thanks everyone for your comments. Enough information to look into. The Delphi language guide looks like a good starting point, this is something the person can do by themselves. @David: your comments include a good list of topics that need to be touched in the learnings. Greetings, Kees Vermeulen
  24. Keesver

    Learning Delphi

    VCL and FMX and Oxygene (much of our code is reused in our web application using WebAssembly)
  25. Keesver

    Learning Delphi

    New to Delphi, they have completed their bachelor's degree in software engineering.
×