Cinemizer Posted June 20, 2020 Posted June 20, 2020 Hello, I would like to get real time data and communicate with the server of XTB. My script below does not work. I do not know how to send JSON commands to the server with socket connection. The server connection is described here: http://developers.xstore.pro/documentation/#communication-with-the-xstation-api They write: Furthermore, WebSockets can be used to connect to the API using the following addresses: wss://ws.xtb.com/demo My code is below, but nothing comes back:, $hRequest is reamain empty (I want to send a Ping to the server, and check if it asnwers, as first step) _______________________________________________________________________________________________ $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, "ws.xtb.com") $hRequest = _WinHttpSimpleSSLRequest($hConnect , "POST" , "/demo" , Default , '{"command":"ping"}' ) _WinHttpSendRequest($hRequest) $bResults = _WinHttpReceiveResponse($hRequest) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) _____________________________________________________________________________________________ This reports error at _WinHttpSendRequest($hRequest), I guess, because hRequest is empty. What is the solution ? (By the way, how can I insert here in this Forum my code so, that it will be showed with colors, like in AutoIT edit field ?) THX ! Spoiler
Musashi Posted June 20, 2020 Posted June 20, 2020 (edited) 9 minutes ago, Cinemizer said: (By the way, how can I insert here in this Forum my code so, that it will be showed with colors, like in AutoIT edit field ?) how-to-post-code-on-the-forum Edited June 20, 2020 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Cinemizer Posted June 20, 2020 Author Posted June 20, 2020 Hello, I would like to get real time data and communicate with the server of XTB. My script below does not work. I do not know how to send JSON commands to the server with socket connection. The server connection is described here: http://developers.xstore.pro/documentation/#communication-with-the-xstation-api They write: Furthermore, WebSockets can be used to connect to the API using the following addresses: wss://ws.xtb.com/demo My code is below, but nothing comes back:, $hRequest is reamain empty (I want to send a Ping to the server, and check if it asnwers, as first step) $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, "ws.xtb.com") $hRequest = _WinHttpSimpleSSLRequest($hConnect , "POST" , "/demo" , Default , '{"command":"ping"}' ) _WinHttpSendRequest($hRequest) $bResults = _WinHttpReceiveResponse($hRequest) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) This reports error at _WinHttpSendRequest($hRequest), I guess, because hRequest is empty. What is the solution ? THX !
Moderators Melba23 Posted June 20, 2020 Moderators Posted June 20, 2020 Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Danp2 Posted June 20, 2020 Posted June 20, 2020 1) You don't want to mix using _WinHttpSimpleSSLRequest with _WinHttpSendRequest and _WinHttpReceiveResponse 2) Have you looked at the example here? Latest Webdriver UDF Release Webdriver Wiki FAQs
Cinemizer Posted June 20, 2020 Author Posted June 20, 2020 THX, it seems to be in the right direction. However the XTB server does not answer. I call the WebSocket example, you sent me with this parameters: Local $sServerName = "ws.xtb.com" Local $sPath = "demo" Local $sMessage = '{"command":"ping"}' I guess, the server should answer something, but he do not. I get this answer: Succesfully upgraded to websocket protocol Sent message to the server: {"command":"ping"} WebSocketReceive error Application failed with error: 0x00002EFE >Exit code: 4294967295 Time: 11.08 According the documentation of XTB the websocket communication goes over ws.xtb.com/demo Where ist the failure ? THX !
Cinemizer Posted June 21, 2020 Author Posted June 21, 2020 (edited) Can it cause, that the server does not answer, because the WebSocket example, you sent me is written for ws message, but the server of XTB is communication over wss ? According the documentation of XTB the websocket communication goes over wss://ws.xtb.com/demo If it is so, could you please tell me, how to change the example script, to be able to send and receive secure wss messages ? THX! Edited June 22, 2020 by Cinemizer
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now