I'm trying to send orders through websockets, but I don't know how to receive the response from the websocket as to whether it was successful or not. The site (https://support.kraken.com/hc/en-us/articles/360034936531-WebSocket-API-Trading-addOrder-and-cancelOrder) says that once the order had been sent, there will be a response outlining whether it was successful or not.
I'm just testing the addOrder with the following code:
async def test():
async for ws in websockets.connect("wss://ws-auth.kraken.com/"):
try:
token = generate_token()
request = {"event": "subscribe", "subscription": {"name": "addOrder", "token": token}}
await ws.send(json.dumps(request))
confirm_connection(await ws.recv())
confirm_subscription(await ws.recv())
volume = 0.0001
leverage = 0
ID = '12345'
request = {'event': 'addOrder', 'token': token, 'reqid': ID, 'ordertype': 'market', 'type': 'buy', 'pair': "XBT/USD", 'volume': volume, 'userref': ID, 'validate': 1}
resp1 = await ws.send(json.dumps(request))
resp2 = await ws.recv()
except websockets.ConnectionClosed:
continue
It connects to the websocket, makes a request for a test trade, sends that off. Then when I try to receive a response (line with resp2 = ...) it just says the following:
'{"errorMessage":"Public market data subscriptions are unavailable on this endpoint. Try ws.kraken.com","event":"subscriptionStatus","status":"error","subscription":{"name":"addOrder","token":"X"}}'
How are you supposed to receive the response as to whether Kraken received the trade request or not?
Thanks in advance
I have no experience with kraken websockets addOrder, but I do have experience with kraken addOrder api and kraken ownTrades and openOrders websocket subscriptions.
I'm guessing here, but judging from the error message, it looks like the error message is a response to a previous websocket subscription call you made requesting to subscribe to a channel data feed (not sure which one though).
With websockets, upon connection, you should get a systemStatus response message. In it, it contains the status ("online" is what you want to check for).
Next, depending on the subscription, you may receive a snapshot message pertaining to that service if it's online. That message will contain recent trade fills (ownTrades subscription), or currently open order (openOrders subscription). I haven't touched individual asset pair subscriptions, but I'm guessing recent activity there will be communicated as well.
I have no idea if anything I've stated herein will help you, but I do know this will definitely help you...
Contact kraken support by logging into your kraken account and then click on Support. I always open a support ticket (no chat, etc.) so that I can provide them with as much detail as I can including what I'm doing, how I'm doing it, and all error messages I'm getting back from them.
To date, they have responded in less than 24 hours and they've always given me very specific answers to my questions (there have been many questions). Overall, I would rate their support minimally 4.5 out of 5 stars.
Good luck.
I figured it out after some time, so this is for anyone else who has this issue.
There were no issues with websocket subscription, it was working as intended. Kraken does a weird thing where they send an error through the websocket, but it really is just a message and can be ignored. The websocket remains open and operational afterwards, so you just need to ignore the first response from the websocket.
Related
When paying in the bot (via payments Sberbank test and Yukassa test (didn't try other acquirers)), the bot responds to update with pre_checkout_query using answerPreCheckoutQuery and receives the response {"ok":true,"result":true}.
But the "BOT_PRECHECKOUT_TIMEOUT" error appears in the payment window. The error occurs on different accounts and different acquirers. The error occurs even if you perform the bot's actions manually.
Is that a problem on my side?
getting pre_checkout_query
answerPreCheckoutQuery
result
InvokeDeviceMethodAsync is intermittently (and only recently) returning a status code of 501 within the responses (the response body is null).
I understand this means Not Implemented. However, the method IS implemented - in fact, it's the only method that is. The device is using Microsoft.Azure.Devices.Client (1.32.0-preview-001 since we're also previewing the Device Streams feature).
Setup, device side
This is all called at startup. After this, some invocations succeed, some fail.
var deviceClient = DeviceClient.CreateFromConnectionString(connectionDetails.ConnectionString, TransportType.Mqtt);
await deviceClient.SetMethodHandlerAsync("RedactedMethodName", RedactedMethodHandler, myObj, cancel).ConfigureAwait(true);
Call, server side
var methodInvocation = new CloudToDeviceMethod("RedactedMethodName")
{
ResponseTimeout = TimeSpan.FromSeconds(60),
ConnectionTimeout = TimeSpan.FromSeconds(60)
};
var invokeResponse = await _serviceClient.InvokeDeviceMethodAsync(iotHubDeviceId, methodInvocation, CancellationToken.None);
What have I tried?
Check code, method registration
Looking for documentation about 501: can't find any
Looking through the source for the libraries (https://github.com/Azure/azure-iot-sdk-csharp/search?q=501). Just looks like "not implemented", i.e. nothing registered
Turning on Distributed Tracing from the Azure portal, with sampling rate 100%. Waited a long time, but still says "Device is not synchronised with desired settings"
Exploring intellisense on the DeviceClient object. Not much there!
What next?
Well, I'd like to diagnose.
What possible reasons are there for the 501 response?
Are there and diagnostic tools, e.g. logging, I have access to?
It looks like, there is no response from the method within the responseTimeoutInSeconds value, so for test purpose (and the real response error) try to use a REST API to invoke the device method.
You should received a http status code described here.
I have the logic below that I am using to peek at the messages on a subscription
var path = EntityNameHelper.FormatSubscriptionPath(TopicName, subscriptionName);
var receiver = new MessageReceiver(connection string, path);
var messages = await receiver.PeekAsync(1000);
When I look at Service Bus Explorer it shows that there are 800 messages on the subscription
However the logic only returns 23
Does anyone know why this happens, is there some kind of caching or something?
Paul
That's by design. Peek and receive operations will return as much as broker can at that specific moment. If you want to retrieve all the messages, you'd have to write some code to iterate over the request one or more time until the number of items you need is reached.
If you want to raise a broker request to clarify this, there's a service issue tracker here.
I make a connection app with rabbitmq, it works fine but when I stop rabbitmq process all of my request get lost, I want even after killing rabitmq service, my requests get saved and after restart rabitmq service, all of my request return to their own places.
Here is my rabitmq.py:
import pika
import SimilarURLs
data = ''
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
def rabit_mq_start(Parameter):
channel.queue_declare(queue='req')
a = (take(datas=Parameter.decode()))
channel.basic_publish(exchange='',
routing_key='req',
body=str(a))
print(" [x] Sent {}".format(a))
return a
channel.start_consuming()
def take(datas):
returns = SimilarURLs.start(data=datas)
return returns
In addition, I'm sorry for writing mistakes in my question.
You need to enable publisher confirms (via the confirm_delivery method on your channel object). Then your application must keep track of what messages have been confirmed as published, and what messages have not. You will have to implement this yourself. When RabbitMQ is stopped and started again, your application can re-publish the messages that weren't confirmed.
It would be best to use the asynchronous publisher example as a guide. If you use BlockingConnection you won't get the async notifications when a message is confirmed, defeating their purpose.
If you need further assistance after trying to implement this yourself I suggest following up on the pika-python mailing list.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.
I have a user receiving the following error in response to an ItemQueryRq with the QuickBooks Web Connector and IIS 7.
Version:
1.6
Message:
ReceiveResponseXML failed
Description:
QBWC1042: ReceiveResponseXML failed
Error message: There was an exception running the extensions specified in the config file. --> Maximum request length exceeded. See QWCLog for more details. Remember to turn logging on.
The log shows the prior request to be
QBWebConnector.SOAPWebService.ProcessRequestXML() : Response received from QuickBooks: size (bytes) = 3048763
In IIS 7, the max allowed content length is set to 30000000, so I'm not sure what I need to change to allow this response through. Can someone point me in the right direction?
Chances are, your web server is rejecting the Web Connector's HTTP request because you're trying to POST too much data to it. It's tough to tell for sure though, because it doesn't look like you have the Web Connector in VERBOSE mode, and you didn't really post enough of the log to be able to see the rest of what happened, and you didn't post the ItemQuery request you sent or an idea of how many items you're getting back in the response.
If I had to guess, you're sending a very generic ItemQueryRq to try to fetch ALL items, which has a high likelihood of returning A LOT of data, and thus having IIS reject the HTTP request.
Whenever you're fetching a large amount of data using the Web Connector, you should be using iterators. Iterators allow you to break up the result set into smaller chunks.
qbXML Iterator example
other qbXML examples
If you just need to determine if an item exists in QB you can simply add IncludeRetElement to your ItemQuery
So you should post something like
<ItemQueryRq requestID="55">
<FullName>Prepay Discount</FullName>
<IncludeRetElement>ListID</IncludeRetElement>
</ItemQueryRq>
And in Item query response just check the status code. If it is equal to 500 then it means that you should push your item into QB, if it is equal to 0 then it means that item exists
That workaround will save plenty of bytes in your response