Jump to content

Dmytro Lendel

Members
  • Content Count

    14
  • Joined

  • Last visited

Community Reputation

1 Neutral
  1. Dmytro Lendel

    THWClient.RequestDone

    Thank you.
  2. Hello, Where I can find error description for ErrCode in OnRequestDone event? THWClient.RequestDone(Sender: TObject; RqType: THttpRequest; ErrCode: Word); Regards, Dmytro
  3. Ok. May be you are right. No reason to discovery the bike Thank you
  4. Hi OverbyteIcsThrdSrvV2 will be good example? Can I do like in OverbyteIcsThrdSrvV2? { TClientThread is our worker thread class. Each time a client connect, a } { new TClientThread is instanciated and client socket attached to it so } { events are processed in the thread's context. } { Remember that multithreading requires synchronization, specially when } { updating GUI or accessing shared data. } { TClientThread uses OnDisplay event to display data on the application } { main form. Synchronization is automatically done. } {$M+} { Needed for Published to take effect } TClientThread = class(TThread) private FWSocket : TWSocket; { Reference to client socket } FMsg : String; { Message to be displayed } FOnDisplay : TDisplayProc; { Event variable } FThreadAttached : Boolean; { TRUE once socket attached } FCritSect : TRTLCriticalSection; procedure DisplayMsg; { Synchronized procedure } public constructor Create(Suspended : Boolean); destructor Destroy; override; procedure Execute; override; { Main method } procedure Display(const Msg : String); { Takes care of synchroniz. } published property WSocket : TWSocket read FWSocket write FWSocket; property ThreadAttached : Boolean read FThreadAttached write FThreadAttached; property OnDisplay : TDisplayProc read FOnDisplay write FOnDisplay; end; { TThrdSrvClient is the class which will be instanciated by server } { component for each new client. N simultaneous clients means N } { TThrdSrvClient will be instanciated. Each being used to handle only a } { single client. } { We can add any data that has to be private for each client, such as } { receive buffer or any other data needed for processing. } TThrdSrvClient = class(TWSocketClient) protected procedure WndProc(var MsgRec: TMessage); override; procedure WMStartCnx(var Msg: TMessage); message WM_START_CNX; public ClientThread : TClientThread; RcvdLine : String; ConnectTime : TDateTime; procedure StartConnection; override; end;
  5. Hi, Thank you so much!
  6. Hello, I need help if you please We used socked server with our devices many years and it works nice. Protocol is ASCII and very simple. Now we start to use thread socked server because we need to make same heavy queries sometimes depends on device`s request. Query is http request with get and post methods. My question is following. Is it safety to call http request from TWSocketThrdClient onClientdata event? As far as I can see TWSocketThrdClient will create own thread inside Socked thread. Correct? What is best way to implement this logic? Hope, somebody will help me Thank you Regards Dmytro
  7. Hello, Problem after calling function HttpPostByStr Next line from client generate exception Invalid point operation and after some time server is crashing I can`t to understand why. Regards, Dmytro
  8. Hello, I changed a little simple OverbyteIcsThrdSrvV2_1 I need create dynamic http request in processdata event and send answer to Client procedure TTcpSrvForm.ProcessData(Client : TThrdSrvClient); Err:String; begin if Copy(Trim(Client.RcvdLine),1,3)='$RQ' then begin Err:=''; HttpPostByStr('{"serialNumber":"98D863E0F226","state":"No data for you"}',Err); Display(IntToHex((Client as TThrdSrvClient).ThreadID,8)+' '+ err); end; end; function HttpPostByStr(SJson: String;var Resp:String):Boolean; var FIDHttp:THttpCli; JsonToSend: TStringStream; ResivdToSend: TStringStream; MyResp,get_url: string; begin Result:=False; MyResp:=''; get_url:='http://194.44.237.46:8087'+'/api/points/states'; JsonToSend := TStringStream.Create('['+SJson+']', TEncoding.UTF8); JsonToSend.Position := 0; ResivdToSend:=TStringStream.Create; FIDHttp:=THttpCli.Create(nil); FIDHttp.ContentTypePost := 'application/json-patch+json'; FIDHttp.Username:='username'; FIDHttp.Password:='pass'; FIDHttp.serverauth:=httpAuthBasic; FIDHttp.URL:=get_url; FIDHttp.SendStream:=JsonToSend; FIDHttp.RcvdStream:=ResivdToSend; Resp:=''; try try FIDHttp.Post; Result:=True; except on E: Exception do begin Resp:= e.Message; end; end; finally ResivdToSend.Seek(0, 0); //Resp='' then Resp:=ResivdToSend.DataString; ResivdToSend.Free; JsonToSend.Free; FIDHttp.Free; end; end; It`s working, but after closing application exception in OverbyteIcsWSocket "Invalid pointer operation" destructor TCustomLineWSocket.Destroy; begin if FRcvdPtr <> nil then begin FreeMem(FRcvdPtr, FRcvBufSize); <-- here FRcvdPtr := nil; FRcvBufSize := 0; end; inherited Destroy; end; Where is my mistake? Regards Dmytro
  9. Dmytro Lendel

    how to send byte array with TWSocketClient

    Thank you!
  10. Dmytro Lendel

    how to send byte array with TWSocketClient

    Hello, How to send byte array with TWSocketClient? I have byte array buffer: array[1..133] of byte I found method Send but it`s working with TBytes PFirmWare = ^TFirmWare; TFirmWare = record buffer: array[1..133] of byte; end; -------------- procedure THWClient.SendXModemLine(Line: integer); var buffer : TBytes; begin if Assigned(SocketClient) then begin if (SocketClient.State=wsConnected) then begin SetLength(buffer, Length(PFirmWare(FXmodemFile.Items[Line])^.buffer)); Move(PFirmWare(FXmodemFile.Items[Line])^.buffer, buffer, Length(PFirmWare(FXmodemFile.Items[Line])^.buffer)); SocketClient.Send(buffer,Length(buffer)); <-- AV is here end; end; end; Can you help me please? Regards Dmytro
  11. Dmytro Lendel

    SSL_CTX_use_certificate:ee key too small

    Hello, I sent request to the vendor about TLS support. I can`t to understand how they implemented it. Hope will have answer soon Thank you! Dmytro
  12. Dmytro Lendel

    SSL_CTX_use_certificate:ee key too small

    Hello, Yes, you right. Welter. I am sorry Step by step. 1 Module is Eport-E20 2 In module`s manual I found “TLS: TLS1.2 encryptioin, We use no certificate method. Only support in TCP client mode.” Module is working in client mode now. Manual attached to this message 3 I added isclogger. Result attached to this letter Regards, Dmytro IOT_Device_Series_Software_Funtion_20200623.pdf 1.txt
  13. Dmytro Lendel

    SSL_CTX_use_certificate:ee key too small

    Thank you very much for your answer. I am a little lost with this problem. I need connect Ethernet module (http://www.hi-flying.com) with TLS encryption support. TLS: TLS1.2 encryption, TLS use no certificate method and I have not ideas what I need to do. Will I need generate new certificate or set some parameters in TSsWSocketServe? I understand how it`s work in theory but don`t know what to do practically. I am sorry. Can you give some help? Regards, Dmytro
  14. Hello, I tried to run demo project OverbyteIcsSimpleSslServer with OverbyteIcsSimpleSslClient. I changed SSLSecLevel to sslSecLevel128bits and I`ve got exception Can't read certificate file "ClientCert.pem" - error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small I need connect network device with TLS support. TLS: TLS1.2 encryptioin, TLS use no certificate method Can you help me? Regards, Dmytro
×