Telegram Http.Get first message Status 202 (Ok) but following messages return Status=0 ?
Telegram Http.Get first message Status 202 (Ok) but following messages return Status=0 ?
27 Mar 2025, 15:07
I am using Http.Get towards Telegram and it has been working fine for many months.
Just recently only the first message in an instance works, then any following messages from that instance do not work (response status=0).
There has been a cTrader update to 5.2.5 which may be the culprit, not sure.
Are others noticing the same behaviour using Telegram ?
Would someone please have a solution for me ?
using cAlgo.API;
using cAlgo.API.Indicators;
using System;
using System.Linq;
using System.Collections.Generic;
[Robot(AccessRights = AccessRights.None, AddIndicators = true)]
private void SendTelegramMessage(string Message, string TelegramToken, string TelegramChatId)
{
// Send message to Telegram
var result = Http.Get($"https://api.telegram.org/bot{TelegramToken}/sendMessage?chat_id={TelegramChatId}&text="+Message);
switch(result.StatusCode)
{
case 0:
Print("Telegram: Status " + result.StatusCode + ": The bot sleeping, wake it up.");
break;
case 200:
Print("Telegram: Status " + result.StatusCode + ": Message sent -> " + Message);
break;
case 400:
Print("Telegram: Status " + result.StatusCode + ": The chat id (" + TelegramChatId + ") is incorrect.");
break;
case 401:
Print("Telegram: Status " + result.StatusCode + ": The bot token (" + TelegramToken + ") is incorrect.");
break;
case 404:
Print("Telegram: Status " + result.StatusCode + ": The bot token (" + TelegramToken + ") or chat id (" + TelegramChatId + ") is missing or incorrect.");
break;
default:
Print("Telegram: " + result.StatusCode + ": Unknown error code.");
break;
}
}
Replies
comidea.it
06 Apr 2025, 18:04
Hi,
same error here... it's a bit frustrating, when you have a code that has been working for months and then you get an unexplained error.
As a developer, I started saying that my code had a problem.. look for a solution.. look here ... look there... but then to my surprise, the problem was an update! well here not having full control of the HTTP library..
I just have to wait for a solution.. or go back to 'FullAccess' mode using the classic httpClient. I wait confidently. Thanks
@comidea.it
Hildeguard
06 Apr 2025, 20:16
RE: Telegram Http.Get first message Status 202 (Ok) but following messages return Status=0 ?
comidea.it said:
Hi,
same error here... it's a bit frustrating, when you have a code that has been working for months and then you get an unexplained error.
As a developer, I started saying that my code had a problem.. look for a solution.. look here ... look there... but then to my surprise, the problem was an update! well here not having full control of the HTTP library..
I just have to wait for a solution.. or go back to 'FullAccess' mode using the classic httpClient. I wait confidently. Thanks
FullAccess mode and classic httpClient doesnt solve the issue for me. Could you give an example for, how this would work right now? I would directly use it..
@Hildeguard
ctid8068054
06 Apr 2025, 23:04
RE: RE: Telegram Http.Get first message Status 202 (Ok) but following messages return Status=0 ?
For now, I have moved away from Spotware cTrader 5.2.5 to a previous version using broker provided cTrader (IC Markets 5.1.14). It is working fine.
@ctid8068054
vegaxlr
09 Apr 2025, 22:07
( Updated at: 11 Apr 2025, 02:57 )
Same problem here. I've tried a lot of "solutions," but nothing works.
If I use this Print: Print($"Exception: {response.Exception}");
I get this:
Exception: cAlgo.API.HttpException: System.InvalidOperationException: This instance has already started one or more requests. Properties can only be modified before sending the first request.
Update: I talked with Spotware support and looks like that is a bug.
We are currently addressing the issue and conducting a thorough review to ensure a proper resolution.
The temporary solution is to install an older version of cTrader.
@vegaxlr
Hildeguard
14 Apr 2025, 11:07
RE: Telegram Http.Get first message Status 202 (Ok) but following messages return Status=0 ?
Can you keep us updated, if you get new information?
vegaxlr said:
Same problem here. I've tried a lot of "solutions," but nothing works.
If I use this Print:
Print($"Exception: {response.Exception}");
I get this:
Exception: cAlgo.API.HttpException: System.InvalidOperationException: This instance has already started one or more requests. Properties can only be modified before sending the first request.
Update: I talked with Spotware support and looks like that is a bug.
We are currently addressing the issue and conducting a thorough review to ensure a proper resolution.
The temporary solution is to install an older version of cTrader.
@Hildeguard
samsulariframdhani
17 Apr 2025, 01:24
( Updated at: 17 Apr 2025, 05:21 )
RE: confirming the issue
Hildeguard said:
Hello,
i am facing the same issue, basically this is also the problem described in https://community.ctrader.com/forum/ctrader-algo-tubidy/46695/
Anyone has a solution?
I have a question and the same problem that occurred with @Hildeguard … Can someone help me or provide the best solution? Thank you so much.
@samsulariframdhani
Hildeguard
31 Mar 2025, 13:58 ( Updated at: 03 Apr 2025, 05:46 )
confirming the issue
Hello,
i am facing the same issue, basically this is also the problem described in https://community.ctrader.com/forum/ctrader-algo/46695/
Anyone has a solution?
@Hildeguard