Invalid binary header. Either incompatible or not a binary message

Hi, im using delhpi rio
client → server using synapsetcp → olympia using supertcpchannel

for callback client → server using indyhttp

im using bin message for synapse and indyhttp, one separte message bin for each one

both message bin using aes envelope

from time to time in only two clients (so far) im getting the error
Invalid binary header. Either incompatible or not a binary message.

until the server/olympia crash or just stop…

i cant really trace to any dataset/function/callback in my system, i will send 2 callstack samples here

this one the system was idle, doing nothing

exception class    : EROInvalidStream
exception message  : Invalid binary header. Either incompatible or not a binary message. ..ihF..&I...i.1....o...e[o..>.Wg.)9.2u...z-...s..8.....Q...'DKs......{hy......$...F...:p.

main thread ($e28):
012e5d6a +2c6 PMedico.exe  uROClasses        393 +16 RaiseInvalidStreamError
013175b3 +08b PMedico.exe  uROBinMessage     646  +6 TBinHeader.CreateFromStream
0131691e +052 PMedico.exe  uROBinMessage     313  +4 TROBinMessage.IntReadFromStream
013173cc +018 PMedico.exe  uROBinMessage     594  +2 TROBinMessage.ReadFromStream
022a29e4 +1f8 PMedico.exe  uROEventReceiver  593 +44 TROEventReceiver.FireEvents 022a17eb +00b PMedico.exe  uROEventReceiver  255  +1 TSyncClass.DoDispatch
0055987d +131 PMedico.exe  System.Classes            CheckSynchronize
007364ff +76b PMedico.exe  Vcl.Forms                 TApplication.WndProc
0055d788 +014 PMedico.exe  System.Classes            StdWndProc
76ba5bfb +00b user32.dll                             DispatchMessageW
00736ed3 +0f3 PMedico.exe  Vcl.Forms                 TApplication.ProcessMessage
00736f16 +00a PMedico.exe  Vcl.Forms                 TApplication.HandleMessage
00737249 +0c9 PMedico.exe  Vcl.Forms                 TApplication.Run
067fa53b +177 PMedico.exe  PMedico          1158 +42 initialization
7611fa27 +017 KERNEL32.DLL                           BaseThreadInitThunk

this one was opeing datasets

exception class    : EROInvalidStream
exception message  : Invalid binary header. Either incompatible or not a binary message. ....!^.uQ.`A..}.....C.6...........$.{F..4.?..6 ..hS.'..=...n..;A.......5!r.........R.9..+.@.

main thread ($3734):
012e5d6a +2c6 PMedico.exe  uROClasses        393  +16 RaiseInvalidStreamError
013175b3 +08b PMedico.exe  uROBinMessage     646   +6 TBinHeader.CreateFromStream
0131691e +052 PMedico.exe  uROBinMessage     313   +4 TROBinMessage.IntReadFromStream
013173cc +018 PMedico.exe  uROBinMessage     594   +2 TROBinMessage.ReadFromStream
022a29e4 +1f8 PMedico.exe  uROEventReceiver  593  +44 TROEventReceiver.FireEvents
022a17eb +00b PMedico.exe  uROEventReceiver  255   +1 TSyncClass.DoDispatch
0055987d +131 PMedico.exe  System.Classes             CheckSynchronize
007364ff +76b PMedico.exe  Vcl.Forms                  TApplication.WndProc
0055d788 +014 PMedico.exe  System.Classes             StdWndProc
7527140b +00b user32.dll                              DispatchMessageW
00736ed3 +0f3 PMedico.exe  Vcl.Forms                  TApplication.ProcessMessage
00736f16 +00a PMedico.exe  Vcl.Forms                  TApplication.HandleMessage
007322b6 +1aa PMedico.exe  Vcl.Forms                  TCustomForm.ShowModal
066e544c +5a0 PMedico.exe  pPrincipal       6079 +104 TfrmPrincipal.ppuAbrirFichaMedica_01
057dee74 +078 PMedico.exe  pInternacao      4912   +8 TfrmInternacao.Ac_FichaMedicaExecute
0055ca33 +00f PMedico.exe  System.Classes             TBasicAction.Execute
005eb37e +086 PMedico.exe  Vcl.ActnList               TCustomAction.Execute
0055c89b +013 PMedico.exe  System.Classes             TBasicActionLink.Execute
0060c590 +05c PMedico.exe  Vcl.Controls               TControl.Click
00631f32 +01e PMedico.exe  Vcl.StdCtrls               TCustomButton.Click
00632a48 +00c PMedico.exe  Vcl.StdCtrls               TCustomButton.CNCommand
0060c04e +2be PMedico.exe  Vcl.Controls               TControl.WndProc
00610b03 +63b PMedico.exe  Vcl.Controls               TWinControl.WndProc
00631bdc +06c PMedico.exe  Vcl.StdCtrls               TButtonControl.WndProc
0060bc88 +024 PMedico.exe  Vcl.Controls               TControl.Perform
00610c67 +023 PMedico.exe  Vcl.Controls               DoControlMsg
006116eb +00b PMedico.exe  Vcl.Controls               TWinControl.WMCommand
0060c04e +2be PMedico.exe  Vcl.Controls               TControl.WndProc
00610b03 +63b PMedico.exe  Vcl.Controls               TWinControl.WndProc
006100d0 +02c PMedico.exe  Vcl.Controls               TWinControl.MainWndProc
0055d788 +014 PMedico.exe  System.Classes             StdWndProc
775c870b +04b ntdll.dll                               KiUserCallbackDispatcher
75271ae1 +041 user32.dll                              SendMessageW
75272972 +082 user32.dll                              CallWindowProcW
00610c12 +0e6 PMedico.exe  Vcl.Controls               TWinControl.DefaultHandler
0060c9f4 +010 PMedico.exe  Vcl.Controls               TControl.WMLButtonUp
0060c04e +2be PMedico.exe  Vcl.Controls               TControl.WndProc
00610b03 +63b PMedico.exe  Vcl.Controls               TWinControl.WndProc
00631bdc +06c PMedico.exe  Vcl.StdCtrls               TButtonControl.WndProc
006100d0 +02c PMedico.exe  Vcl.Controls               TWinControl.MainWndProc
0055d788 +014 PMedico.exe  System.Classes             StdWndProc
7527140b +00b user32.dll                              DispatchMessageW
00736ed3 +0f3 PMedico.exe  Vcl.Forms                  TApplication.ProcessMessage
00736f16 +00a PMedico.exe  Vcl.Forms                  TApplication.HandleMessage
00737249 +0c9 PMedico.exe  Vcl.Forms                  TApplication.Run
067fa53b +177 PMedico.exe  PMedico          1158  +42 initialization
76557d57 +017 KERNEL32.DLL                            BaseThreadInitThunk

to clarify, when i say two clientes, i mean two separete server application with multiple clients each one, and the error seems to propagate to every client in that server

Hi,

this error is raised if stream isn’t started with RO107 (this is default signature for bin message):

constructor TBinHeader.CreateFromStream(Source: TStream);
begin
  inherited Create();
  Source.ReadBuffer(fHeader, SizeOf(fHeader));
  if not SignatureValid then begin
..
    RaiseInvalidStreamError(err_InvalidHeader, [], Source);  //<<<<<<<<<<<<<<
  end;
end;

Can you create a simple testcase that reproduces this issue, pls?
You can drop it to support@ for keeping privacy

well. no i cant reproduce, thats the main reason im posting

im having from time to time this problem, i cant trace to any action im doing

Hi,

some ideas:

  • try to temporary disable aes envelope and retest.
  • try to grab stream in callback_channel.OnReceiveStream event on client-side. I have suspicion that something is going wrong at decryption of incoming stream. stream should start with RO107 or rorocks signature.

Ty, will try to disabled aes, not sure when i will give a feedback on this, like i said is random today we have 0 erros until now, is not everyday, or even every week