EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Event on finish sending bytes

Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.
#32884
Posted: 04/01/2015 15:13:07
by Leonardo Herrera (Standard support level)
Joined: 02/14/2011
Posts: 66

Hello,

I'm using TElHTTPSClient to send some information to a remote server. Our normal way to do things is to send the information to the server and then the server would respond with some special message to let us know that they received the info (ticket number, state, etc.)

The problem is that today the connection timed out because the remote server was extremely busy. However, their side did receive the data but we didn't get the acknowledge. So the question: is it possible to know when the TElHTTPSClient has finished _sending_ all the data that was there to send, in case the server times out when responding?
#32885
Posted: 04/01/2015 16:08:36
by Ken Ivanov (EldoS Corp.)

Hi Leonardo,

Thank you for contacting us.

Building a transactional system on top of a simple application-layer request-response protocol, like HTTP, might be a challenge. Even if you trace the fact that you've sent out all the data, there will be no guarantee that the server has actually processed it. Even though the server might have read the data from socket, the data might have stuck on that stage without going further up the stack through TLS and/or application layer handlers.

A typical solution here is assigning a unique identifier to each operation request and including it with the request. Then you'll be able to use that identifier after a stalled attempt to query the server about the status of the operation later.

Getting back to your question, you can use OnProgress event to get information about the amount of data actually sent to the socket and the total amount of data to be sent within the request. The value of the Current parameter becoming equal to the value of the Total parameter is an indicator that the whole request has been sent out to the socket.

Ken
#32886
Posted: 04/01/2015 16:25:14
by Leonardo Herrera (Standard support level)
Joined: 02/14/2011
Posts: 66

Quote
Getting back to your question, you can use OnProgress event to get information about the amount of data actually sent to the socket and the total amount of data to be sent within the request. The value of the Current parameter becoming equal to the value of the Total parameter is an indicator that the whole request has been sent out to the socket.


Ah, this might work. Once I have a hint that the data *may* have been received by the server, I want to make sure I don't lose it (so I'll save it and I can check with my partner offsite.)

Thank you very much!
#32887
Posted: 04/02/2015 00:11:32
by Eugene Mayevski (EldoS Corp.)

The problem is that all OnProgress informs you is that the data has been written to the socket buffers locally. They might not even be sent to the remote computer yet. This situation is not much better than knowing nothing at all - the only way to confirm that the data has reached the destination is to get a confirmation from the destination.


Sincerely yours
Eugene Mayevski
#32908
Posted: 04/02/2015 08:37:00
by Leonardo Herrera (Standard support level)
Joined: 02/14/2011
Posts: 66

Eugene,

That's true. But if I know by fact that I didn't finish sending all the data, at least I can discard the local copy completely and ask the user to try again later. But if for some reason the data reached the server and I just didn't get the acknowledge, I cannot send the document again (the customer will get a nasty warning email from our Tax office about sending repeated invoices, which is not good).

On this same vein, I'm attaching a filestream (which I know the size) together with some headers. What is the total size reported by TElHTTPSClient in the OnProgressEvent? It is only the size of the body (in this case, the file size) or it is the whole deal, headers and all?

Regards!
#32910
Posted: 04/02/2015 08:48:19
by Eugene Mayevski (EldoS Corp.)

You can't know that the data has reached the server, unless you get the receipt. if you have put all data to the buffer and you think the data has been sent, and the tax office doesn't receive anything in the end, this is a far worse situation than the duplicate submission.


Sincerely yours
Eugene Mayevski
#32920
Posted: 04/02/2015 13:19:07
by Leonardo Herrera (Standard support level)
Joined: 02/14/2011
Posts: 66

There are some other facts that I didn't mentioned - the tax office receives the invoice and they respond with a generic ticket number. Then you have to check against this number to see if they processed the invoice, and if it was accepted or rejected.

The good thing is that invoices always can be checked without this ticket number afterwards: this means if that I'm not sure they received the invoice, I can always check later on if they have it and if it has been accepted.

I think I'll change my current approach (save the ticket number and generated invoice on a succesful response of the server) to a more conservative one: generate the invoice on my side and always save it, only dropping it if I'm positive the tax office server rejected it for any reason.

Thank you very much for your feedback!
Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.

Reply

Statistics

Topic viewed 717 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!