Buy contract says I need to authorize after authorization

I figure in this scenario the issue normally is that the websocket closes before i do the actual buy request. But I don't see how.

I am doing this through c#, here's a simplified version of the send method:

public async Task SendRequest(string data)
var reqAsBytes = Encoding.UTF8.GetBytes(data);
var ticksRequest = new ArraySegment(reqAsBytes);
await ws.SendAsync(ticksRequest, WebSocketMessageType.Text, true, CancellationToken.None);

I use the same method but with a different data json string. First I authenticate using my token. The result of that is:

"{\"authorize\":{\"allow_omnibus\":0,\"balance\":\"10000.00\",\"country\":\"th\",\"currency\":\"USD\",\"email\":\"\",\"fullname\":\" \",\"is_virtual\":1,\"landing_company_fullname\":\"Binary Ltd\",\"landing_company_name\":\"virtual\",\"loginid\":\"VRTC1562452\",\"scopes\":[\"read\",\"trade\",\"payments\",\"admin\"],\"sub_accounts\":[]},\"echo_req\":{\"authorize\":\"NAAhohZ6QCJA35O\"},\"msg_type\":\"authorize\"}"

Then I send my buy contract using the same method, but my result shows:

"{\"echo_req\":{\"buy\":1,\"parameters\":{\"amount\":5000,\"barrier\":0.7582,\"barrier2\":0.7551,\"basis\":\"payout\",\"contract_type\":\"CALL\",\"currency\":\"USD\",\"date_expiry\":\"1502451285\",\"duration\":4,\"duration_unit\":\"h\",\"proposal\":1,\"symbol\":\"frxAUDUSD\"},\"price\":100},\"error\":{\"code\":\"AuthorizationRequired\",\"message\":\"Please log in.\"},\"msg_type\":\"buy\"}"

I don't close my websocket anywhere, and it should stay alive for 30s by default (i confirm i checked the default value), so I don't understand why this is not working.

Any idea?


  • Please paste the code as its hard to debug or conclude like this. You need to pipe your buy request after authorize response has come and as per question you are doing it, so need to check code snippet to evaluate

Sign In or Register to comment.