API websocket: empty response on calling proposal_open_contract

edited March 2016 in General

Hi Guys,

Thank you for such a nice API, I really love it, thanks for your work. I'm writing a bot for my own, but somehow sometimes Web Socket returns me an empty response on proposal_open_contract method. What can be the reason?
BTW, I checked the limitations and it looks fine for me because the bot is doing ~60 proposal_open_contract, proposal, buy requests per hour, so ~180 requests per hour overall. And at the beginning it was working very well for about ~40 hours in a row, but then I started to get empty responses from time to time on calling proposal_open_contract method and it breaks my bot =\

Usually after my bot stops working - I identify that it has stopped only after ~4 hours and I restart the bot. And I keep getting empty responses each ~130 stakes (each stake means 1 proposal_open_contract, 1 proposal, 1 buy requests - so duration of each stake is ~60 seconds).

Please help me to find out a solution for this issue.

Comments

  • @VKim can you please send the request you are sending and response that you are getting?

  • edited April 2016

    @Raunak, yes, sure, here they are:

    REQUEST
    {
    "proposal_open_contract": 1,
    "contract_id": 8326962408
    }

    RESPONSE

    So, response is really just empy.. May be there are some whitespaces, but nothing else. No any JSON data.

    BTW, I noticed one interesting thing - if I restart my bot after crash in less than 4 hours - the bot gets empty response earlier, i.e. after ~40 stakes. Seems like I'm triggering some limitations for Opening Contract, WDYT? =\

  • {
    "proposal_open_contract": 1,
    "contract_id": 8326962408
    }
    

    can you make this call individually and check for response? In response may be your getting error as structure for error response changes, it would be something like this

    {
      echo_req: {}, 
      error: {
        code: 'GetProposalFailure',
        message: 'Invalid something'
      },
      msg_type: 'proposal_open_contract'
    }
    

    even for limitation you would get error that RateLimit has reached

  • edited April 2016

    @Raunak
    Running this request individually is returning me this JSON with no errors ( just did this from both your API playground and my program):
    {
    "echo_req": {
    "contract_id": 8326962408,
    "proposal_open_contract": 1
    },
    "proposal_open_contract": {
    "exit_tick_time": "1459478200",
    "barrier": "610.5338",
    "date_settlement": 1459478201,
    "contract_id": "8326962408",
    "exit_tick": "611.0644",
    "underlying": "R_50",
    "currency": "USD",
    "entry_tick": "610.5338",
    "current_spot": "598.9354",
    "date_start": 1459478141,
    "purchase_time": 1459478141,
    "is_intraday": 1,
    "is_expired": 1,
    "is_valid_to_sell": 1,
    "shortcode": "CALL_R_50_4.18_1459478141_1459478201_S0P_0",
    "bid_price": "4.18",
    "is_forward_starting": 0,
    "longcode": "USD 4.18 payout if Random 50 Index is strictly higher than entry spot at 1 minute after contract start time.",
    "is_sold": 0,
    "is_path_dependent": 0,
    "date_expiry": 1459478201,
    "account_id": "29245108",
    "entry_tick_time": "1459478142",
    "ask_price": "4.18",
    "entry_spot": "610.5338",
    "buy_price": "2.15",
    "current_spot_time": "1459498636",
    "payout": "4.18"
    },
    "msg_type": "proposal_open_contract"
    }

    What my program actually reports me when the bot fails is something like "can't parse JSON" - sure, because of empty response from Web Socket on calling Open Contract method. I handle this exception in code and make the program to print the content of reply I get from Web Socket if exception occurs. And I can see that the response is just empty, really empty =\

    The IP address of machine where my program is operating is 104.236.190.64

    What really makes me wondering is that the program was working really well for the first ~40 hours and then it started to periodically get empty responses on calling Open Contract method (other 2 methods I use seem to be working really well). And the behavior is the very same for other trial accounts I have (3 ones overall).

    Please help me to stabilize its behavior, it is a real blocker for me. If nothing works I'm thinking to check the contract state and result by calling Statement method, but sure, it is not the best alternative.
    I still continue testing, hope to come back to you ASAP with more number of interesting facts about this abnormal behavior.

  • @VKim we would need more response information else it will be hard to debug for us. So you websocket connection remains open for 40 hours or you create new connection?

  • @Raunak
    For the first time I kept it opened for ~40 hours without reconnecting/reauthenticating and it worked fine. But since I started to face this issue - I reconnect and re-authenticate each ~90 minutes, but it doesn't help.

  • @Raunak

    need more response information

    I use Golang 1.6 for my program. Please let me know what information I can provide you to help with debugging this issue.

  • @Raunak

    Just tried to check results by requesting statement - facing the very same issue oO. Statement method returns empty response from time to time =|

  • @VKim if its ok with can you paste your code here else send message to @Kaveh he can help you with go programming

  • Hi @Raunak, @Kaveh ,
    Sure, np
    Please find the source code in the attached

  • @VKim I deleted your post that included your source code.

    Vkim which package are you using to unmarshal your json.
    Also can you tell me what you are receiving that you are trying to unmarshal (string of what you read and you try to unmarshal)?

  • @Kaveh

    Roger

    I'm using package "responses" to unmarshal json I get from WebSocket:
    all structs defined in this package are just object models of JSON I get from WebSocket. These structs are BuyContract, OpenContract, Balance, PriceProposal, Statement, TickHistory.

    I use only: BuyContract, OpenContract, PriceProposal
    Function SendMessage is sending json request to WebSocket and returning json response as string. So I take this string and cast it to types of BuyContractJson or OpenContractJson or PriceProposalJson (which are basically of string type too). Each of this types has method ToStruct() which unmarshal json and returns BuyContract struct or OpenContract struct or PriceProposal struct.

    Normally in response from WebSocket I get the following JSON strings:
    PRICE_PROPOSAL response
    {
    "echo_req": {
    "symbol": "R_100",
    "duration": "60",
    "currency": "USD",
    "amount": "100",
    "proposal": 1,
    "basis": "payout",
    "duration_unit": "s",
    "contract_type": "CALL"
    },
    "proposal": {
    "longcode": "USD 100.00 payout if Random 100 Index is strictly higher than entry spot at 1 minute after contract start time.",
    "spot": "35716.02",
    "display_value": "51.47",
    "ask_price": "51.47",
    "spot_time": "1460637368",
    "date_start": 1460637369,
    "id": "7731F13E-023D-11E6-B5A2-BF2903C8895E",
    "payout": "100"
    },
    "msg_type": "proposal"
    }

    PRICE_PROPOSAL_OPEN_CONTRACT response
    {
    "echo_req": {
    "contract_id": 8293254968,
    "proposal_open_contract": 1
    },
    "proposal_open_contract": {
    "date_settlement": 1459307720,
    "contract_id": "8293254968",
    "sell_time": 1459358076,
    "underlying": "R_50",
    "validation_error": "This contract has been sold.",
    "date_start": 1459307660,
    "is_expired": 1,
    "is_valid_to_sell": 0,
    "shortcode": "CALL_R_50_0.97_1459307660_1459307720_S0P_0",
    "is_forward_starting": 0,
    "bid_price": "0.97",
    "is_sold": 1,
    "is_path_dependent": 0,
    "entry_spot": "590.3535",
    "current_spot_time": "1460637748",
    "exit_tick_time": "1459307720",
    "barrier": "590.3535",
    "sell_spot_time": "1459358076",
    "exit_tick": "590.5791",
    "currency": "USD",
    "sell_price": "0.97",
    "entry_tick": "590.3535",
    "current_spot": "636.3577",
    "purchase_time": 1459307660,
    "transaction_ids": {
    "buy": "16435480268",
    "sell": "16459479328"
    },
    "contract_type": "CALL",
    "is_intraday": 1,
    "longcode": "USD 0.97 payout if Random 50 Index is strictly higher than entry spot at 1 minute after contract start time.",
    "display_name": "Random 50 Index",
    "date_expiry": 1459307720,
    "sell_spot": "609.7962",
    "entry_tick_time": "1459307662",
    "ask_price": "0.97",
    "buy_price": "0.5",
    "payout": "0.97"
    },
    "msg_type": "proposal_open_contract"
    }

    BUY_CONTRACT response
    mm.. a bit tricky to track from API Playground )) I skip it if you don't mind

    I start thinking that empty json string in responses are related to some limitations of your hosting provider or to some security policies... not sure. WDYT, can it be the root of the issue?

  • Seems like from now on it doesn't metter how long pauses I take between lunches of bot. I face this issue once per ~30 iterations.

  • @Raunak @Kaveh

    Guys, do you have any news?

Sign In or Register to comment.