not able to connect to mysql from botpress
# 🤝help
I have created a flask endpoint to connect to mysql database to insert some data. I am running this on ngrok and it is online In botpress in the execute code node, I am trying to call this API.
Copy code
async function submitDataToAPI() {
  const feedbackData = {
    // "user_name": workflow.username,
    // "user_phone": workflow.userPhone,
    "user_name": "ram",
    "user_phone": "91234567890",
    "start_time": workflow.usertimestart,
    "end_time": workflow.usertimeend,
    "messages": conversation.SummaryAgent.transcript,
    "feedbackgiven": workflow.FeedbackGiven


    const options = {
    uri: '',
    method: 'POST',
      'Content-Type': 'application/json',
      'Content-Length': '99999'
    data: feedbackData
    //data: JSON.stringify(feedbackData)

    console.log('before axios')
    await axios(options)
    console.log('after axios')
    console.log('Feedback submitted successfully')
  } catch(error){
    console.error('Error submitting Feedback: ', error)

It works fine when I use it in Postman and records are created in db, but when I try the same in botpress, I get errors in logs. Is there anything wrong with how I call the API in botpress?
ECONNREFUSED stands for “Connection Refused By Server.” That means the server you are trying to connect to has refused the connection request. Simply put, it means that your server is inaccessible. This error message is quite common and often shows up when using File Transfer Protocol (FTP) clients like FileZilla.
But the same is working when I hit the API via postman, it should work on botpress also right
It should. I have used Botpress with Ngrok before without any issues. Can you make sure that it's calling the same endpoint
Can you go through the body and the headers and make sure that it's not missing something
I have rechecked the headers and body, I am using the same headers in botpress as well. I am not able to understand why botpress is checking at port 80 when I have mentioned port 5000 (default port for flask) [b9506744ae] [bot-action] [flow:Conversation End] [node:Standard2] [card:Submit Feedback Data to Flask API]: Error submitting Feedback: {"message":"connect ECONNREFUSED","name":"Error","stack":"Error: connect ECONNREFUSED\n at zm.from (/var/task/customer_code.js:303:8883)\n at N.handleRequestError (/var/task/customer_code.js:306:9063)\n at N.emit (node:events:517:28)\n at m. (/var/task/customer_code.js:57:950)\n at ClientRequest.emit (node:events:517:28)\n at Socket.socketErrorListener (node:_http_client:501:9)\n at Socket.emit (node:events:517:28)\n at emitErrorNT (node:internal/streams/destroy:151:8)\n at emitErrorCloseNT (node:internal/streams/destroy:116:3)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["xhr","http"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"*/*","Content-Type":"application/json","Content-Length":"99999","Accept-Encoding":"gzip, deflate, br","Connection":"keep-alive","User-Agent":"axios/1.4.0"},"withCredentials":false,"baseURL":"","uri":"http://localhost:5000/api/submit_feedback","method":"post","port":5000,"
Have you forwarded port 5000?
Doesn't even matter
Your endpoint is wrong
Try and use Ngrok again, and make sure the ports match
Fyi you shouldn't send your forwarded address from Ngrok here 🙂
Looks like it might be trying port 80?
Yes, But I am not understanding why it is using port 80. Do you know how we can force it to use port 5000?
Maybe something is set up wrong
It is working now, I just made the change from axios(options) to