plastkort
Members-
Content Count
41 -
Joined
-
Last visited
Everything posted by plastkort
-
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 ?
-
Thanks, would there be any example source code I can check to see how this websocket works ?
-
i'd sure give this a test, but I am not sure where I can find this download link?
-
hi! I have been playing with the tought on playing with websockets and rest API. i got the documentation on how to connect but encrypion stuff is hard to swallow, is there any tricks on how to solve this little easter egg ? var param_str : string; secret : string; begin Secret := 't7T0YlFnYXk0Fx3JswQsDrViLg1Gh3DUU5Mr'; param_str := 'api_key=B2Rou0PLPpGqcU0Vu2&leverage=100&symbol=BTCUSD×tamp=1542434791000'; sign := hex(HMAC_SHA256($secret, $param_str)); end; result should be sign = 670e3e4aa32b243f2dedf1dafcec2fd17a440e71b05681550416507de591d908 any solution is OK, but cannot affford anything that costs... help 🤪🤪
-
hi folks! have anyone here tried to remote trigger Canon EOS cameras taking photos from your own delphi applications?
-
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
-
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.
-
im trying to use a very old component i made for delphi 7 back in the days, i havent touched it for many years. but it installed ok without a problem, however when i go to the component list and want to add it.. it seems to be "faded" and cannot be added... why is it so ? it works if i create a new application and try to add it...
-
A proper way to set up a listening socket (WebHook)
plastkort posted a topic in ICS - Internet Component Suite
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; -
A proper way to set up a listening socket (WebHook)
plastkort replied to plastkort's topic in ICS - Internet Component Suite
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. -
A proper way to set up a listening socket (WebHook)
plastkort replied to plastkort's topic in ICS - Internet Component Suite
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 -
A proper way to set up a listening socket (WebHook)
plastkort replied to plastkort's topic in ICS - Internet Component Suite
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 ? -
A proper way to set up a listening socket (WebHook)
plastkort replied to plastkort's topic in ICS - Internet Component Suite
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 -
hi!  I am currently testing out websockets with TSSLWSocket, since i cannot find a good component which is free to handle this i had to create one myself.. it works on some server but the server i need to make it work with says i have to request on server, not client. I did see there was an option called SSLMode which can be set to either client or server, when I set it to server, i get a connection, but i don't get any further answer from the server after this,..  is there another eventhandler for the data or am I missing something else here ? sidenote: i always get disconnected as well after a few seconds
-
thanks. I will try this
-
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==
-
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?
-
ok, but this gets disconnected instantly, the onconnect and ondisconnect gets triggered, but thats it it works fine ifi try another service to connect
-
obviously it does not like me.. Connection gets established, but it just immediately disconnects me.. i don't recevive a single byte from the server... the other server i used (bitmex) works like a charm,. but this "bybit" does not communicate.. im not sure what the difference is... websocket testing works normally. i am not sure if there is any properties i need to change which i missed
-
I got a littlebit further now, but it seems im getting socketerror 10053 now, not sure where the culprit is here . but I will do some digging
-
nope, extra CRLF did not help. the function SendStrLF is just Sendstr procedure which just auto adds #13#10 to end of every line.. just to make it more readable... this connection works on another websocket service I used perfectly. however the answer from the support team was a bit cryptic to me when i don't really know all the tech stuff on SSL, but basically its just json communication over SSL socket... theire team answered this, which maybe a clue to whats happening ? "We do not allow Cross-origin resource sharing (CORS) on our WebSocket API. Kindly use the server end to subscribe our Websocket API directly"
-
Aha! I don't really know what's going on here, but i compare with a chrome extension whats happening when i connect.. It says : GET wss://stream.bybit.com/realtime HTTP/1.1 Host: stream.bybit.com Connection: Upgrade Pragma: no-cache Cache-Control: no-cache User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36 Upgrade: websocket Origin: chrome-extension://pfdhoblngboilpfeibdedpjgfnlcodoo Sec-WebSocket-Version: 13 Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9,nb;q=0.8,no;q=0.7,nn;q=0.6,th;q=0.5 Sec-WebSocket-Key: DdNU4DODQxp7NlzjW2U5xQ== Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits this extension works.. so i try to send the following from my program SendStrLF(Format('GET %s HTTP/1.1', [TradeCouple])); SendStrLF('Accept-Encoding: gzip, deflate, br'); SendStrLF('Accept-Language: en-US,en;q=0.9,nb;q=0.8,no;q=0.7,nn;q=0.6,th;q=0.5'); SendStrLF('Cache-Control: no-cache'); SendStrLF('Connection: Upgrade'); SendStrLF('Host: stream.bybit.com'); SendStrLF('Origin: chrome-extension://pfdhoblngboilpfeibdedpjgfnlcodoo'); SendStrLF('Pragma: no-cache'); SendStrLF('Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits'); SendStrLF('Sec-WebSocket-Key: k1Yxf1UeGyDXhyKx2tmr9A=='); SendStrLF('Sec-WebSocket-Version: 13'); SendStrLF('Upgrade: websocket'); SendStrLF('User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'); this does not work, server just replies error 301... . really frustrating why its not working cause i can see no difference here 🙂
-
hi! I am currently testing out websockets with TSSLWSocket, since i cannot find a good component which is free to handle this i had to create one myself.. it works on some server but the server i need to make it work with says i have to request on server, not client. I did see there was an option called SSLMode which can be set to either client or server, when I set it to server, i get a connection, but i don't get any further answer from the server after this,.. is there another eventhandler for the data or am I missing something else here ?
-
posted this in ICS thread.. how do i delete this ?
-
Have been digging everywhere around the web for a solution that allows me to play simple wave files simultaneously... i found some examples but none of them works soundplay works with only a single file at a time even if i create them in a TThread, i tried to change and tweak it, but for now i have given up, so now I am asking if anyone of you have experience with this before, any library that can help, i am not really interrested in using an external program as a via shell execute since it can slow things down. would be perfect if there was a working windows API that just plays the sound and with no hassle.. mciSendString does not work at all either for me