Jump to content

plastkort

Members
  • Content Count

    41
  • Joined

  • Last visited

Community Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. plastkort

    Websockets

    Thanks, would there be any example source code I can check to see how this websocket works ?
  2. plastkort

    Websockets

    i'd sure give this a test, but I am not sure where I can find this download link?
  3. plastkort

    Websockets

    Earlier I made my own version for a specific websocket connection, however now it seems that the service I connect to has changed something and I have no clue what. I can still connect to them using openSSH directly, however with my modified TSSLWsocket I can no longer connect, It just immediately disconnects with the error code 10053 (wsaeconnaborted) i tried to reboot routers and modems but still nothing. application I made was connected on another computer which eventually died the next time I tried to start it. so I suspect that i might need some other kind of websocket component, but hopefully I can still use TSSLWsocket, anyone here have something I can use ?
  4. plastkort

    Controlling Canon EOS cameras

    this one i havent tried, i found another one with the same name that diid not seem to do much. I will take a look at this one, i also know canon have an SDK kit, but not sure if creating a wrapper for delphi will be easy. will see
  5. hi folks! have anyone here tried to remote trigger Canon EOS cameras taking photos from your own delphi applications?
  6. plastkort

    Webhook example

    i think the only way is to create one yourself, but for the community i think it would be good to have more of these new socket services... I am currently using a webhook from tradingview for alert notifications, but i guess it's not really the same webhook, more or less its just sending a post to my own server.
  7. I can take a look at TWSocketServer, I think i used it before, but maybe 6-7 years ago. As a sidenote, i think the shutdown(2) and close did the trick i think. program still accepting connections after 2 days.
  8. hmm.. it seems this appserver will overcomplicate my simple project.. I did however notice something in your sample files called: OverbyteIcsSrv5 i use "FNewSocket := _TWSocket(sender).Accept;" but i did not apply the FnewSocket := TWSocket(sender).dup is this a very important part i was missing ? also i have added : ShutDown(2); Close; and will see if this allows my server to live longer, note, it's only the listening socket that died earlier, and not the rest of my program. however im not sure if it just stopped listen or something else messed it up
  9. That one might do the trick, but i hope it can be simplified. I just require it to receive a POST message, and just reply a simple instruction page on the default. but I would also appreciate if you have any answer to why my listening socket just stops listening after a while, im concerned that this happens on other projects i might be planning to do in the future. are there any sample codes around I can take a look at so i know that i do everything right ?
  10. I looked at it, and it seems it needed a HTML folder, I just need to answer a few lines. this works for me. for a short time. but the listening socket seems to die
  11. hi! I have been using TWSocket erarlier to create listening sockets, but this is several years back, now i have a case where i need to make it work again. I got it to listen, but it eventually dies after some time, it could be 1 hour or 1 day. I do the following: First i create the listening socket: wsTradingWebHook.addr:='0.0.0.0'; wsTradingWebHook.port:='80'; wsTradingWebHook.Listen; When incoming I do the following: procedure TDataFunctions.wsTradingWebHookSessionAvailable(Sender: TObject; ErrCode: Word); var html : TStringlist; FMySocket : TWSocket; begin FMySocket := Twsocket.create(self); html := TStringlist.Create; with FMySocket do try OnDataAvailable := wsTradingWebHookDataAvailable; HSocket := twsocket(sender).Accept; html.add('<html><head>'); html.add('<title>Welcome to WhaleAlert</title>'); html.add('</head><body>'); html.add('Usage: <br>'); html.add('{ "signal": "short", "message": "short signal on 5 minutes" } <br>'); html.add('{ "signal": "long", "message": "long signal on 5 minutes" } <br>'); html.add('</body></html> sendstr('HTTP/1.1 200 OK'#13#10); sendstr(format('Date: %s GMT+2'#13#10,[formatdatetime('ddd, dd mmm yyyy hh:mm:ss', date)])); sendstr('Server; myserver'#13#10); sendstr('Content-Type: text/html; charset=iso-8859-1'#13#10); sendstr(format('Content-length=%d'#13#10,[length(html.Text)])); sendstr(#13#10); sendstr(html.Text); sendstr(#13#10); finally freeAndNil(html); end; end; When I receive data from the server i handle it like this: ( I just want the json data received, so any data prior to the { and } will be deleted) I am unsure if i need the "TWSocket(sender).Free;" is needed, or the socket will just clean itself, if i try connect with a normal webserver i receive the "info" message, but the client still seem to wait for more data...i.e. the waiting circle keeps spinning... function TDataFunctions.ProcessWebHook(Received : string) : string; var PostCommand : string; begin result := ''; if pos('POST',received) <> 0 then begin PostCommand := received; if (pos('{',PostCommand) <> 0) and (pos('}',PostCommand) <> 0) then begin Delete(postcommand, 1, pred(pos('{',PostCommand))); Result := PostCommand; end; end; end; procedure TDataFunctions.wsTradingWebHookDataAvailable(Sender: TObject; ErrCode: Word); var ProcessedCommand : string; Signal : string; TrayIcon : TRzTrayIcon; UserData : ISuperObject; ReceivedJSON : AnsiString; begin try ProcessedCommand := ProcessWebHook(AnsiString(TSslWSocket(Sender).ReceiveStr)); if (trim(ProcessedCommand) <> '') then try TrayIcon := frmMain.MyTrayicon; UserData := SO(ProcessedCommand); if userdata.s['signal'] = 'short' then begin Signal := userdata.s['message']; AddSignal(signal, false); end; if userdata.s['signal'] = 'long' then begin Signal := userdata.s['message']; AddSignal(signal, true); end; finally TWSocket(sender).Free; end; except AddSignal(ProcessedCommand, false,true); end; end;
  12. plastkort

    TSSLWSocket (repost)

    thanks. I will try this
  13. plastkort

    TSSLWSocket (repost)

    A bit more digging, obviously there are properties i need to set i think, but which one... using linux plus gnutls-cli gave these results : root@debian:/var/www/html# gnutls-cli stream.bybit.com:443 Processed 128 CA certificate(s). Resolving 'stream.bybit.com:443'... Connecting to '143.204.47.65:443'... - Certificate type: X.509 - Got a certificate list of 4 certificates. - Certificate[0] info: - subject `CN=*.bybit.com', issuer `CN=Amazon,OU=Server CA 1B,O=Amazon,C=US', serial 0x0383cade2595390d1e981419f44bf25f, RSA key 2048 bits, signed using RSA-SHA256, activated `2018-10-13 00:00:00 UTC', expires `2019-11-13 12:00:00 UTC', pin-sha256="7mhRzLK5Z7Q+sqQckWvcD8HwrOOA4L79f7roFhuTMqc=" Public Key ID: sha1:9503e077751ee70cd099b80c3e87e725a6a3ba68 sha256:ee6851ccb2b967b43eb2a41c916bdc0fc1f0ace380e0befd7fbae8161b9332a7 Public Key PIN: pin-sha256:7mhRzLK5Z7Q+sqQckWvcD8HwrOOA4L79f7roFhuTMqc= - Certificate[1] info: - subject `CN=Amazon,OU=Server CA 1B,O=Amazon,C=US', issuer `CN=Amazon Root CA 1,O=Amazon,C=US', serial 0x067f94578587e8ac77deb253325bbc998b560d, RSA key 2048 bits, signed using RSA-SHA256, activated `2015-10-22 00:00:00 UTC', expires `2025-10-19 00:00:00 UTC', pin-sha256="JSMzqOOrtyOT1kmau6zKhgT676hGgczD5VMdRMyJZFA=" - Certificate[2] info: - subject `CN=Amazon Root CA 1,O=Amazon,C=US', issuer `CN=Starfield Services Root Certificate Authority - G2,O=Starfield Technologies\, Inc.,L=Scottsdale,ST=Arizona,C=US', serial 0x067f944a2a27cdf3fac2ae2b01f908eeb9c4c6, RSA key 2048 bits, signed using RSA-SHA256, activated `2015-05-25 12:00:00 UTC', expires `2037-12-31 01:00:00 UTC', pin-sha256="++MBgDH5WGvL9Bcn5Be30cRcL0f5O+NyoXuWtQdX1aI=" - Certificate[3] info: - subject `CN=Starfield Services Root Certificate Authority - G2,O=Starfield Technologies\, Inc.,L=Scottsdale,ST=Arizona,C=US', issuer `OU=Starfield Class 2 Certification Authority,O=Starfield Technologies\, Inc.,C=US', serial 0x00a70e4a4c3482b77f, RSA key 2048 bits, signed using RSA-SHA256, activated `2009-09-02 00:00:00 UTC', expires `2034-06-28 17:39:16 UTC', pin-sha256="KwccWaCgrnaw6tsrrSO61FgLacNgG2MMLq8GE6+oP5I=" - Status: The certificate is trusted. - Description: (TLS1.2)-(ECDHE-SECP256R1)-(RSA-SHA512)-(AES-128-GCM) - Session ID: E7:38:E2:7E:73:4B:E7:6C:46:1B:40:82:C5:79:B9:83:39:1C:70:E7:40:69:D2:51:9E:AB:E3:60:6B:83:02:30 - Options: safe renegotiation, - Handshake was completed - Simple Client Mode: GET wss://stream.bybit.com/realtime HTTP/1.1 Host: stream.bybit.com Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Origin: http://example.com Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13 HTTP/1.1 101 Switching Protocols Connection: upgrade Date: Thu, 29 Aug 2019 21:39:13 GMT Upgrade: websocket Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= X-Cache: Miss from cloudfront Via: 1.1 f00e3524edcdf61801454f2bb21e71ce.cloudfront.net (CloudFront) X-Amz-Cf-Pop: OSL50-C1 X-Amz-Cf-Id: pF49hcINxgI6bYbor7C0cWbdBq8Q53_CA9kJ36JmwYi41ZIv2PPSyQ==
  14. plastkort

    TSSLWSocket (repost)

    after some digging, I decided to test indy, which gave some other error message Project Project17.exe raised exception class EIdOSSLUnderlyingCryptoError with message 'Error connecting with SSL. error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure'. what do i need to set in the SSLContext to get compatibility?
  15. plastkort

    TSSLWSocket (repost)

    ok, but this gets disconnected instantly, the onconnect and ondisconnect gets triggered, but thats it it works fine ifi try another service to connect
×