httpcallbackwsgigroupme

Why would a callback URL not work (for a GroupMe bot)?


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!


Solution

  • 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.