0

I am creating a GroupMe bot, and I'm testing out the callback URL and the basic WSGI app I've set up so far. I am planning host the bot on Heroku, but am testing it on my local machine first. I registered a bot, with the callback URL http://MY_IP_ADDRESS:8000. When I open a different shell and run requests.post('http://MY_IP_ADDRESS:8000', data = 'something') in the Python interpreter, everything works fine. However, when there is activity in the GroupMe group, nothing happens, not even an error message.

Here's my (simplified) code:

from wsgiref.simple_server import make_serve  

def app(environ, startResponse):

    try:
        requestBodySize = int(environ.get('CONTENT_LENGTH', 0))
    except ValueError:
        requestBodySize = 0

    # requestBody = environ['wsgi.input'].read(requestBodySize)
    print('something') 

    responseBody = bytes('successful', 'utf-8') 

    status = '200 OK'
    responseHeaders = [('Content-Type', 'text/plain'), ('Content-Length', str(len(responseBody)))]

    startResponse(status, responseHeaders)

    return [responseBody]

server = make_server('', 8000, app)
server.serve_forever()

I'm sure I'm doing something obvious, but I can't for the life of me figure out what. I'd appreciate any help!

2 Answers2

0

I never figured out why the callback URL wasn't working with localhost, but when I deployed the app on Heroku, everything worked fine! It must have had something to do with my firewall settings.

0

When you run servers on your local machine your firewall doesn't really like that. GroupMe also cant send to anything but public facing addressees, which is why Heroku works. One thing I can recommend in the future is using Ngrok, https://ngrok.com/ this will work with your server to make a public facing address on your machine that you can use as callback url. I use Ngrok to test my bots and quickly iterate before pushing to a dedicated server like Heroku, honestly looking through Heroku log files is a pain...