Coder Social home page Coder Social logo

Comments (9)

axblueblader avatar axblueblader commented on June 15, 2024 1

Yes all info are guaranteed to be correct.
Because this will work:

    let bot = LineBot::new(channel_secret.as_str(), access_token.as_str());
    let mut messages: Vec<SendMessageType> = Vec::new();
    messages.push(SendMessageType::TextMessage(TextMessage {
        text: String::from("Pushed"),
        emojis: None,
    }));
    let result = bot.push_message(line_id, messages);

But this will fail with that error:

    let bot = LineBot::new(channel_secret.as_str(), access_token.as_str());
    let mut messages: Vec<SendMessageType> = Vec::new();
    
    let res = bot.get_profile(line_id);
    let _profile = res.unwrap();

    messages.push(SendMessageType::TextMessage(TextMessage {
        text: String::from("Pushed"),
        emojis: None,
    }));
    let result = bot.push_message(line_id, messages);

from line-bot-sdk-rust.

axblueblader avatar axblueblader commented on June 15, 2024 1

I think it might a bug in the http client or reqwest http client lib (maybe a thread or socket race condition?).
When debugging, if I step slowly through each function in the debugger, the push_message call will be successful.
Running normally will always get 400.
Hope this info is useful

from line-bot-sdk-rust.

nanato12 avatar nanato12 commented on June 15, 2024

thanks @axblueblader
please show me the error message when it fails.

from line-bot-sdk-rust.

axblueblader avatar axblueblader commented on June 15, 2024

Hi @nanato12 , here is the response log
I set log level to TRACE but that's all I got, sorry, couldn't find other useful error message.
It just works properly when remove bot.get_profile call

Ok(Response { url: Url { scheme: "https", username: "", password: None, host: Some(Domain("api.line.me")), port: None, path: "/v2/bot/message/push", query: None, fragment: None
    }, status: 400, headers: {
        "server": "AkamaiGHost",
        "mime-version": "1.0",
        "content-type": "text/html",
        "content-length": "216",
        "expires": "Thu, 15 Apr 2021 06:36:28 GMT",
        "date": "Thu, 15 Apr 2021 06:36:28 GMT",
        "connection": "close"
    }
})

from line-bot-sdk-rust.

nanato12 avatar nanato12 commented on June 15, 2024

add "println" and check the response message.
and show me.

let result = bot.push_message(line_id, messages);
println!("{:?}", result.unwrap().text());

scchot

UserID length is 33.

if length is not 33 or "Uxxxxxx" (x is hex) , response is Ok("{\"message\":\"The property, \'to\', in the request body is invalid (line: -, column: -)\"}").
if UserID is invalid, response is Ok("{\"message\":\"Failed to send messages\"}")

from line-bot-sdk-rust.

axblueblader avatar axblueblader commented on June 15, 2024
    println!("user id length: {:?}", line_id.len());
    let _res = bot.push_message(line_id, messages);
    println!("bot.push_message: {:?}", _res.unwrap().text());

Length is 33
Here is response text

Ok("<HTML><HEAD>\n<TITLE>Bad Request</TITLE>\n</HEAD><BODY>\n<H1>Bad Request</H1>\nYour browser sent a request that this server could not understand.<P>\nReference&#32;&#35;7&#46;6fb42d17&#46;1618478740&#46;0\n</BODY>\n</HTML>\n")

from line-bot-sdk-rust.

nanato12 avatar nanato12 commented on June 15, 2024

LINE_CHANNEL_SECRET and LINE_CHANNEL_ACCESS_TOKEN correct?

from line-bot-sdk-rust.

nanato12 avatar nanato12 commented on June 15, 2024

thanks @axblueblader
It works without any trouble in my environment.
I don't know the exact cause.
Sorry....

from line-bot-sdk-rust.

axblueblader avatar axblueblader commented on June 15, 2024

ye, it could be the Rust version or something
anyways thanks for looking into it

from line-bot-sdk-rust.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.