Closed Shakirsadiq6 closed 3 months ago
Hey! feel free to post the error message and I can help clarify what needs to be changed
Hi @sshh12 Thanks for replying
I tried to run the code using gunicorn for the deployment purpose: I ran this command: gunicorn -k gevent main:TwilioServer
main is the name of my py file which consists the code of examples folder of this repository.
The server started but I got 500 error:
Traceback (most recent call last):
File "/Users/apple/Desktop/December/xincon-calling-bot-twilio/env/lib/python3.10/site-packages/gunicorn/workers/base_async.py", line 55, in handle
self.handle_request(listener_name, req, client, addr)
File "/Users/apple/Desktop/December/xincon-calling-bot-twilio/env/lib/python3.10/site-packages/gunicorn/workers/ggevent.py", line 128, in handle_request
super().handle_request(listener_name, req, sock, addr)
File "/Users/apple/Desktop/December/xincon-calling-bot-twilio/env/lib/python3.10/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request
respiter = self.wsgi(environ, resp.start_response)
TypeError: TwilioServer.__init__() missing 1 required positional argument: 'static_dir'
[2023-12-18 11:03:54 +0530] [4897] [ERROR] Error handling request /
Traceback (most recent call last):
File "/Users/apple/Desktop/December/xincon-calling-bot-twilio/env/lib/python3.10/site-packages/gunicorn/workers/base_async.py", line 55, in handle
self.handle_request(listener_name, req, client, addr)
File "/Users/apple/Desktop/December/xincon-calling-bot-twilio/env/lib/python3.10/site-packages/gunicorn/workers/ggevent.py", line 128, in handle_request
super().handle_request(listener_name, req, sock, addr)
File "/Users/apple/Desktop/December/xincon-calling-bot-twilio/env/lib/python3.10/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request
respiter = self.wsgi(environ, resp.start_response)
TypeError: TwilioServer.__init__() missing 1 required positional argument: 'static_dir'
[2023-12-18 11:03:54 +0530] [4897] [ERROR] Error handling request /favicon.ico
Traceback (most recent call last):
File "/Users/apple/Desktop/December/xincon-calling-bot-twilio/env/lib/python3.10/site-packages/gunicorn/workers/base_async.py", line 55, in handle
self.handle_request(listener_name, req, client, addr)
File "/Users/apple/Desktop/December/xincon-calling-bot-twilio/env/lib/python3.10/site-packages/gunicorn/workers/ggevent.py", line 128, in handle_request
super().handle_request(listener_name, req, sock, addr)
File "/Users/apple/Desktop/December/xincon-calling-bot-twilio/env/lib/python3.10/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request
respiter = self.wsgi(environ, resp.start_response)
TypeError: TwilioServer.__init__() missing 1 required positional argument: 'static_dir'
@sshh12 could you please me with this?
Hey @Shakirsadiq6, I'm still traveling for the holidays. Will get back to you in a week or so.
Sure thanks @sshh12 I'll waiting for you response.
Enjoy your holidays!
Hm ok this might be tricky. I'm not sure if some of the way this was written will work with guincorn/gevent so my advice would be just to use this as-is and if you want parallel serving you could run multiple instances with different local ports. Then use something like nginx to load the balance between these. Will also note that you do not need ngrok for your own domain name as long as the flask server (or nginx) is exposed to the internet.
As for this specific exception, I think this issue is the command main:TwilioServer
, the second part should be the module of the wsgi server so potentially main:deploy_app
.
I actually saw the other issue on this repo where you said to do the parallel serving.
Indeed I don't want to use the ngrok, I want to use my own domain.
Both main:TwilioServer
and main:deploy_app
didn't work.
Is there any way by which I can deploy it? With or without gunicorn
Just want to clarify, you don't need gunicorn to use this with your own domain without ngrok.
For your domain, you can just set TwilioServer
port to 80
and then point your domain to your server's public IP address (e.g., with an A
record). No code change is required.
Hi @sshh12 I was using the ngrok as my issue for the deployment wasn't fixed but I had some issues while using ngrok. I tried to use my public IP and domain also. But I am facing 405 error on incoming-voice route. But if I pass both the methods ["GET", "POST"], it doesn't throw an error but also doesn't respond with anything:
GET /incoming-voice?msg=Gather+End&Called=%2B15169166898&Digits=1&ToState=NY&CallerCountry=US&Direction=inbound&CallerState=NY&ToZip=&CallSid=CA039d114cc39d45540c0947096312d6f8&To=%2B15169166898&CallerZip=10118&ToCountry=US&FinishedOnKey=&CalledZip=&ApiVersion=2010-04-01&CalledCity=&CallStatus=in-progress&From=%2B12125609218&AccountSid=ACf5e9dcf64ba02a384e75c68198a9dcec&CalledCountry=US&CallerCity=NEW+YORK&ToCity=&FromCountry=US&Caller=%2B12125609218&FromCity=NEW+YORK&CalledState=NY&FromZip=10118&FromState=NY HTTP/1.1" 405 308 0.000808
I would double check your twilio settings, this is what I'm using:
From what you posted it looks like it's using a GET whereas code is written for POST only.
OK @sshh12 thanks for the response. I have same things selected in the twilio and I have modified your code a lot. I have a language selection panel and then once a user selects the language they get redirected to a new url where they start conversation with my custom LLM. I think maybe I have some issue with the code which I have added over your code.
Thanks for the help. I'll let you know if I need any further help.
I need to deploy the app on the server but I am not able to do it as I was using gunicorn and nginx to deploy. Could you please guide me for its deployment, so I can use my domain name instead of the ngrok.
I tried the below changes but it didn't work I got port already in use error at WSGIServer line