Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultipartRequest weird behavior using Telegram API #69

Closed
muniz95 opened this issue Mar 17, 2017 · 11 comments
Closed

MultipartRequest weird behavior using Telegram API #69

muniz95 opened this issue Mar 17, 2017 · 11 comments
Labels
needs-info Additional information needed from the issue author type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@muniz95
Copy link

muniz95 commented Mar 17, 2017

Hi. I am developing a bot wrapper for Telegram, and I am using MultipartRequest class to send a file from my local machine to the Telegram servers, but I am facing a 504 error all the time. No matter the parameters I'm using, I get this error after a long waiting time.

Even without any file attached this actions results in an error. Here is a snippet of the code I'm using. A simple curl with exactly the same parameters is successful.

As far as I tested, this only occours with Telegram.

@nex3
Copy link
Member

nex3 commented May 15, 2017

Are you using http 0.11.3+12? That includes a multipart bug fix that might fix your issue.

@nex3 nex3 added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) needs info labels May 15, 2017
@muniz95
Copy link
Author

muniz95 commented May 16, 2017

I just tested it with version 0.11.3+13, and the Gateway Timeout is still happening.

@nex3
Copy link
Member

nex3 commented May 17, 2017

In that case, I need more information to determine what's different between the requests we're sending and those curl is sending. If you can provide a standalone example—one that doesn't require telegram's servers—that chokes on our multipart requests, that would be great. Otherwise, you may have to do some trial-and-error with manual HTTP requests to figure out exactly what it is about our requests that's causing Telegram to choke.

@graddotdev
Copy link

#62

@muniz95
Copy link
Author

muniz95 commented Dec 27, 2017

Sorry for the VERY late response. I am using the newest version of http (0.11.3+16)
Here is a snippet of my code:

main() {
  // I created a new bot in order to test it, so this token actually works
  String uri = 'https://api.telegram.org/bot511.../sendPhoto';
  var request = new MultipartRequest("POST", uri);
  // var file = new File('${dirname(Platform.script.path)}/photo.jpg').readAsBytesSync();
  var requestFile = await MultipartFile.fromPath('photo', '${dirname(Platform.script.path)}/photo.jpg');
  request.fields['chat_id'] = '299327540';
  request.files.add(requestFile);
  request
    .send()
    .then((response) => print(response.reasonPhrase));
}

The file photo.jpg is placed in the same folder of the script. I am still unable to send any file using this method

@nex3
Copy link
Member

nex3 commented Jan 2, 2018

I still need more information about the difference between what's happening at a protocol level here between http and curl.

@muniz95
Copy link
Author

muniz95 commented Jan 3, 2018

The curl command I used for tests is the following:

/usr/bin/curl -F "chat_id=012345" -F "audio=@'/path/to/audio.mp3'" 'https://api.telegram.org/bot511055718:AAFM5QO7w-Yt1v6-wjIdaqI2ylA50voSln4/sendAudio'

I am not using any extra header, except the multipart/form-data where necessary. The requests are basically the same.

@nex3
Copy link
Member

nex3 commented Jan 3, 2018

I need to see the actual bytes that are being sent to the server in each case—I don't want to try to reproduce this locally and risk messing with your bot or whatever.

@muniz95
Copy link
Author

muniz95 commented Jan 3, 2018 via email

@nex3
Copy link
Member

nex3 commented Jan 3, 2018

I'm trying to reproduce this with a curl call, but I keep getting 400 errors with the description "Bad Request: chat not found".

Copy link

github-actions bot commented Nov 1, 2024

Without additional information we're not able to resolve this issue. Feel free to add more info or respond to any questions above and we can reopen the case. Thanks for your contribution!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-info Additional information needed from the issue author type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants