Jump to content

Remy Lebeau

Members
  • Content Count

    2335
  • Joined

  • Last visited

  • Days Won

    94

Everything posted by Remy Lebeau

  1. UTF8String exists in C++Builder too, and does the same implicit conversion to UTF-8 when assigned other string types.
  2. Remy Lebeau

    how to flush buffers on Indy components

    I really wanted to see your actual raw messages, not your code. But whatever. From the code you have shown, it appears that your messages are formatted as XML. In which case, you can recover from a non-socket error by reading bytes from the IOHandler until the next opening XML element is encountered. For instance, you can call IOHandler.WaitFor('<', False, False) to ignore all bytes until a '<' character becomes available at the front of the InputBuffer, and then call IOHandler.CheckForDataOnSource()+IOHandler.InputBuffer.Peek() to see if subsequent byte(s) contain a valid message name. If not, call IOHandler.Discard() to ignore the unwanted byte(s) and repeat the WaitFor()+Peek() until a valid message is detected. Eventually, you should encounter the beginning of a valid message in the InputBuffer and can then resume your normal reading.
  3. There is no way to diagnose this without seeing your actual code AND a log of the raw TLS handshakes that are producing the "protocol version" alerts. Is it possible that the sites in question are requiring TLS 1.3? Are other web browsers able to connect without error? Have you tried comparing their TLS handshakes to the ones Indy produces? Have you tried the WIP SSLIOHandler for OpenSSL 1.1x/3.0 yet, and does it produce the same errors?
  4. Remy Lebeau

    how to flush buffers on Indy components

    I have asked you multiple times now to please provide an example of your actual communication in action, but you have not done so yet. I CANNOT help you in implementing recovery logic without seeing a real example. For all I know, your protocol simply CAN'T recover the way you want. That is a likely possibility, many common protocols can't recover without disconnecting the socket and reconnecting. If you do not provide a real example of a file transfer with surrounding messaging, then there is nothing I can do.
  5. Remy Lebeau

    Creating my own .bpl

    Using a .bpl in an app, you should NOT have to use the .pas/.dcu files directly in the app. If your app is still building/requiring the .pas/.dcu files, then it is not correctly referencing the component unit(s) from the .bpl.
  6. Remy Lebeau

    how to flush buffers on Indy components

    Without knowing more about your actual protocol, I can't answer that. Is the transfer being done on the same connection that initiates the transfer (ala HTTP)? Or, is it on a separate connection (ala FTP)? How does the receiver know what the FileSize is? Does the receiver receive anything at the end of the transfer that it could look for if the transfer fails with a non-socket error? I ask this, because if the transfer fails with a non-socket error, you will only know how many bytes were written to the XferStream, but not necessarily how many bytes were actually consumed from the socket itself. So, the only way to recover without disconnecting/reconnecting is if you have a definitive way to identify where a new message begins after a transfer is finished.
  7. Remy Lebeau

    TIdHTTPProxyServer hangs when used with RemObjects

    You are right, my bad. Didn't realize there was another person on this thread.
  8. Remy Lebeau

    TIdHTTPProxyServer hangs when used with RemObjects

    I have checked in a new branch with some changes for TIdHTTPProxyServer: https://github.com/IndySockets/Indy/tree/http-proxy-keepalive Let me know if it works OK, and then I'll merge it in to the main code. I also opened a ticket in Indy's repo: https://github.com/IndySockets/Indy/issues/425
  9. Remy Lebeau

    TIdHTTPProxyServer hangs when used with RemObjects

    No, there is not. Handling CONNECT is very different than handling other HTTP verbs. A CONNECT request just contains the target host/port to connect to, and then all data between client and target server is tunneled back and forth as-is. But any other HTTP verb is a full HTTP request sent to the proxy itself, containing the full target URL, so the proxy will have to parse and forward the request as needed. And HTTP proxies are allowed to modify a request and/or response as it wants (unless the client asks the proxy not to do that, but TIdHTTPProxyServer does not implement that feature at this time). If you want a straight passthrough, look at TIdMappedPortTCP instead. But to make that work as an HTTP proxy, you will have to parse the HTTP protocol manually in its OnConnect, OnExecute, and OnOutboundData events. That is the default behavior for HTTP 0.9 and HTTP 1.0, but in HTTP 1.1 onward the default behavior is to keep the connection open instead, and the client has to explicitly ask the remote server to close the connection after sending a response. Looking at TIdHTTPProxyServer again, I see it uses HTTP 1.0 when communicating with the remote server, so it closes the remote connection after each response, and it will also close the connection with the requesting client after each response too. I'll have to update TIdHTTPProxyServer to support keep-alives. A CONNECT is a straight passthrough of raw data back and forth, the proxy does not process the data in any way. That is not the case when handling other HTTP verbs. That is incorrect. If the response has a 'Connection: keep-alive' (HTTP 0.9/1.0) header, or does not have a 'Connection: close' (HTTP 1.1+) header, the HTTP client is required by the HTTP specs to parse the response to discover when it actually ends, specifically because a disconnect WON'T occur at the end in that situation. Makes sense, as TIdHTTPProxyServer does not support keep-alives at this time. I'll have to update it to handle the 'Connection' and 'Proxy-Connection' headers better. It shouldn't even be getting that far, since the disconnect should happen before TIdHTTPProxyServer attempts to read the next request from the client. Yes, because TIdCommandHandler.Disconnect is set to True in TIdHTTPProxyServer.InitializeCommandHandlers() for all proxy requests. Good to know, thanks. Currently, it does, because TIdHTTPProxyServer does not implement proper handling of HTTP keep-alives at this time. Though, it doesn't really seem to be handling non-keepalives properly, either. It should be passing around 'Connection: close' and 'Proxy-Connection: close' headers, at least until keep-alives can be implemented. Not that I can think of. The proxy uses HTTP 1.0 to communicate with the remote server, so it already disconnects from the server after each response. As long as the client wants to stay connected to the proxy, it could send subsequent requests to the proxy, and each one will be forwarded individually. Though, I would not suggest setting Disconnect=False in TIdHTTPProxyServer.InitializeCommandHandlers(). I would leave it as True as a fallback, and then set TIdCommand.Disconnect=False inside of TIdHTTPProxyServer.CommandPassThrough() after reading the client's request headers, so that the keep-alive can be handled on a per-request basis. I'll update TIdHTTPProxyServer to handle that. I know what CONNECT is. And what you describe is how TIdHTTPProxyServer handles CONNECT right now. But an HTTP client won't use CONNECT for HTTP verbs like HEAD/GET/POST unless they are used over HTTPS, since CONNECT is required to let the client negotiate SSL/TLS security directly with the remote server through an HTTP proxy. Otherwise, the client would be negotiating SSL/TLS with the proxy instead, which would then subject the requests to MITM attacks.
  10. Related: Getting exception HRESULT: 0x80040265 with MP4 Files
  11. Remy Lebeau

    TIdHTTPProxyServer hangs when used with RemObjects

    It would be nice if the "Call started" and "Call completed" messages logged WHAT operation(s) were being started/completed. And also, if every Call start/sent/reading message included the PeerPort that is processing the Call, to better differentiate between Calls that overlap in parallel. The Call numbers alone are making it confusing which client is performing which action when Calls overlap. Logging the PeerPort instead on everything should remove that ambiguity. Is it possible/expected that any given "Call" in your client code produces multiple HTTP requests at a time? Or, is it expected to be only 1 HTTP request per "Call"? Connections to the target server are not re-used. There is 1 new connection per request forwarded. The connection with a client stays open as log as the client wants. There can be multiple requests per connection to the proxy. And your client is requesting keep-alives with the proxy, though most connections are sending only 1 request per connection. But Call 6 appears to share a TCP connection with an unknown Call number, and that 2nd call is difficult to determine what is actually happening on it. It might have hung, or not, I can't tell yet. I can't comment on that, since I don't see that in your code. Possibly, if the client uses HTTP keep-alives to reuse a connection for multiple HTTP requests. As it does appear really happened for at least 2 Calls. It is certainly possible that TIdHTTPProxyServer may not be handling that situation correctly, since it is not a fully functional HTTP server. I might have to force "Connection: close" on every response until that can be verified/addressed. Synchronize what, exactly? It should not be. Provided you are not blocking the exception then all Indy servers should be handling it to close the socket and stop the thread. No. I have not looked at the 2nd log yet, I will do so shortly. The 1st log was not easy to follow. But this does go back to my comment above that there possibly could be an issue with TIdHTTPProxyServer not correctly handling multiple requests on the same TCP connection through HTTP keep-alives. That only applies to the listening Binding sockets, to reuse ports that were previously closed and then reopened in a short amount of time.
  12. Remy Lebeau

    Conditional compiling - Delphi has a bug

    This seems to be the opposite of documented behavior in Delphi: https://docwiki.embarcadero.com/RADStudio/en/IF_directive_(Delphi) So, {$IF FPC_VERSION >= 3} SHOULD just evaluate to False, and if it is not then this is likely a regression.
  13. Did you make sure they were successful? In any case, I'm not sure this IS the root cause, only that it is ONE POSSIBLE cause. Like I mentioned, there are other reasons for that error to occur. I suggest you enable Debug DCUs and step into the FMX source code with the debugger to see what is REALLY happening inside the TMediaPlayer. Not that I'm aware of. MP4 is one of the supported file extensions on Windows. But that does not rule out the possibility that the MP4 file itself is bad in some way.
  14. Make sure CoInitialize() or CoInitializeEx() is being called at program startup.
  15. That error happens if TMediaPlayer can't instantiate DirectShow's Graph Builder object (did you initialize the COM library beforehand?), or can't query the builder for the necessary video renderer interfaces, or the builder can't load the file to render it.
  16. Remy Lebeau

    TIdHTTPProxyServer hangs when used with RemObjects

    I don't understand what this log is supposed to be showing me. Looks like every request received is responded to, and each connection is closed. What am I missing? What is the actual problem, exactly? Using HTTPS through an HTTP proxy requires use of the CONNECT verb, which is just a straight passthough tunnel of raw data from the client to the target server and back. TIdHTTPProxyServer does not attempt to interpret the raw data in any way, all it is doing is managing the 2 TCP connections involved. Whereas, using HTTP through an HTTP proxy requires sending HTTP requests to the proxy itself, and then the proxy makes its own HTTP requests to the target server. So TIdHTTPProxyServer by default is fully reading and interpreting your client's requests and then replicating them to the target server. So sure, there could certainly be some glitches in that process. TIdHTTPProxyServer is not a full HTTP server or HTTP client, it is quite bare-bones, so it is not outside the realm of possibility that RemObjects is sending its HTTP requests in a way that TIdHTTPProxyServer can't handle correctly. Or, because TIdHTTPProxyServer uses HTTP 1.0 when communicating with the target server, there could be differences between its use of HTTP 1.0 and the client's use of HTTP 1.1 that is causing interference. Hard to say for sure. I'm speculating, because I have no way to actually test/debug this at the moment. Something else to consider - by default, TIdHTTPProxyServer.DefaultTransferMode is set to tmFullDocument, which means for GET/POST/HEAD requests, TIdHTTPProxyServer will read the client's entire request into memory before then passing it along to the target server, and then read the server's entire response into memory before then passing it along to the client. This allows the user's application code to modify the request/response data if desired before passing it along. Do you have the same problem if you set TIdHTTPProxyServer.DefaultTransferMode to tmStreaming instead? That will cause TIdHTTPProxyServer to not buffer the request/response data in memory, it will be passed along as it is being received (at the cost that application code can't modify it anymore).
  17. Remy Lebeau

    Delphi CE 10.4.2 - Command Line Compilation

    Well, that sucks
  18. Remy Lebeau

    exceptions and static storage duration objects

    I'm just going off of the actual code you posted earlier. That tends to happen when the runtime/debugger can't interpret the actual exception object at the level it was detected at, basically treating it as an "unknown" exception type. Did you not see the quote I posted earlier? https://en.cppreference.com/w/cpp/language/function-try-block Minor nitpicks: the A() constructor is not public, and std::exit() takes an exit code integer instead of a string as input. In any case, when I test the code outside of C++Builder (which I don't have installed at the moment), the code works fine when using std::exit() in the function-try's catch handler: https://onlinegdb.com/WqiBtg8dD https://onlinegdb.com/v7B8acNo4 And terminates the process with a re-thrown exception when not using std::exit() in the handler: https://onlinegdb.com/q0KLc6Cne https://onlinegdb.com/rHqvw5kmo
  19. What is the actual error? What version of C++Builder are you using, and what platform(s) are you attempting to play the MP4 on? Did you verify the MP4 is valid to begin with? Can you play it with other software players? What kind of artifacts?
  20. I just answered that on StackOverflow, go see my update.
  21. <sigh> And here we go again... This is a followup to these StackOverflow questions: https://stackoverflow.com/questions/73313071/ https://stackoverflow.com/questions/73254575/
  22. Remy Lebeau

    Good example of what exceptions TIdHTTP cielt can raise

    Indy has a few hundred unique exception classes defined, so it is not really feasible to give you a comprehensive list of them all. However, most of them are specialized to specific components only, so you don't have to worry about most of them. All Indy exceptions are derived from EIdException. And then for TIdHTTP specifically, you could potentially get any of the following derived exceptions raised (this is not an exhaustive list, there might be others I missed): EIdHTTPProtocolException (HTTP error response from server) EIdUnknownProtocol (requesting a non-HTTP/S URL with no target port specified) EIdIOHandlerPropInvalid (requesting HTTPS URL but no SSLIOHandler is assigned) EIdReadTimeout EIdSocketError (base class for all socket-related exceptions, may also be raised as-is) EIdInternetPermissionNeeded (Android only, for now) EIdConnClosedGracefully EIdClosedSocket EIdNotConnected EIdNotASocket What is wrong with just catching Exception/EIdException and displaying its Message property? Mosst Indy exceptions have message texts assigned to them.
  23. Remy Lebeau

    Save Timage picture as png

    In which case, you should be getting an EConvertError exception raised, not a corrupted/empty file created.
  24. Remy Lebeau

    exceptions and static storage duration objects

    There is no call to exit() in the code you presented. In the code you presented, you have 2 separate object instances of the A class: A a; // <-- here A & AccessA() { static A obj; // <-- here return obj; } The 1st object is being created in global scope during program startup, and the 2nd object is being created in static memory the first time AccessA() is called at runtime. The global object is created before your project's WinMain() function is executed The code presented is not calling AccessA() at all, so the compiler/linker is free to optimize it away, if it wants to. I already explained that in detail in my previous reply. Go re-read it again more carefully. Do you understand the difference between a function-try block and a normal non-function-level try block? No, there is no explicit re-throw statement in the catch block. But the catch block is performing an implicit re-throw, because you are using a function-try block instead of a normal try block: If you really want to swallow the exception, use a normal try block instead of a function-try block, eg: class A { A() noexcept { try { throw std::logic_error("test"); } catch (std::exception const &ex) { std::cout << "Caught an STL exception" << std::endl; } } }; Notice the try-catch is now inside the constructor's body, rather than around the body as in your original example.
  25. Remy Lebeau

    cdecl

    That is normal behavior. That is also normal behavior. Calling conventions like cdecl and stdcall simply don't exist in 64bit, and they are ignored completely when used in code. There is only 1 standardized 64bit calling convention, and its behaviors are dictated by the 64bit ABI. And the 64bit calling convention indeed does not use the same name mangling rules that the 32bit cdecl calling convention uses. Use a .DEF file to control how the linker (or IMPLIB tool) formats exported names, and what internal names those exported names map to.
×