#1 2018-05-24 01:21:08

keinn
Member
Registered: 2014-10-20
Posts: 103

websocket client callback theading problem

question:how the webscoket client callback work? is it running in thread ? how to perform NoBlocking on client side?

while testing the sample 31: Project31ChatServer.dpr and Project31ChatClient.dpr. the default code works .
but if made one small change on the client side callback as such:

procedure TChatCallback.NotifyBlaBla(const pseudo, msg: string);
begin
  TextColor(ccLightBlue);
  writeln(#13'@',pseudo,' ',msg);
  TextColor(ccLightGray);
  write('>');
  sleep(60000); //just test the slow process
end;

and modify the procedure Run; make it send 10000 Blabla Requests as such:

     TextColor(ccLightGray);
     write('>');
     readln(msg);
     if msg='' then  exit;
     i:=0;
      repeat
        Service.BlaBla(pseudo,msg);
      until i=10000;

run  such modified client  , and the UnModified client together,  just for a short while, the client will raize:

 TInterfacedObjectFakeClient.FakeCall(IChatService.BlaBla) failed: 'URI root/ChatService.BlaBla ["888888888888","88888888888"] returned status 'Not Found' (404 - Network problem or request timeout)'

it seems due to the TChatCallback.NotifyBlaBla callback service take too long to process ,the webscoket client is closed by the server .
so my question is : when it's call by server, what thread does  the websocket callback implemetion running in? ie:TChatCallback.NotifyBlaBla(const pseudo, msg: string);

is it thread safe? and seems "NoBlocking" is not implement on both side

Last edited by keinn (2018-05-24 01:29:24)

Offline

#2 2018-05-24 05:46:38

keinn
Member
Registered: 2014-10-20
Posts: 103

Re: websocket client callback theading problem

after deep dive into the synopse online doc, i think , the Client.ServiceNotificationMethodViaMessages(); will solve the problem.

but , another case, i use the websocket client in dll , and the dll is loaded by a third party exe ,not coded in delphi~~ wanna cry.

Offline

Board footer

Powered by FluxBB