Heroku和扭曲 [英] Heroku and Twisted

查看:141
本文介绍了Heroku和扭曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Twisted,一个Python框架,并且我想把一个基本的应用程序联机,当它收到一条消息时将它发送回去。我决定使用Heroku来托管它,然后我按照他们的文档上的说明进行操作。

I am trying to learn Twisted, a Python framework, and I want to put a basic application online that, when it receive a message sends it back. I decided to use Heroku to host it, and I followed the instructions on their docs.

import os
from twisted.internet import protocol, reactor

class Echo(protocol.Protocol):
    def dataReceived(self, data):
        self.transport.write(data)

class EchoFactory(protocol.Factory):
    def buildProtocol(self, addr):
        return Echo()

port = int(os.environ.get('PORT', 5000))
reactor.listenTCP(port, EchoFactory(), interface = '0.0.0.0')
reactor.run()

所有工作除了(我知道这是一个愚蠢的问题),我如何发送消息给它?当我在本地工作时,我只做 telnet localhost< port> ,但现在我不知道。
另外,因为heroku连接到一个随机端口,我怎么知道它连接到我的应用程序的端口?
Thanks。

Its all working except (and I know this is a stupid question), how do I send a message to it? When I am working locally I just do telnet localhost <port>, but now I have no idea. Also, since heroku connects to a random port how can I know what port it connects my app to? Thanks.

推荐答案

我对Twisted不是很熟悉,但我不确定你是什么Heroku支持试图做的事情。 Heroku目前仅支持HTTP [S]请求,而不支持原始TCP。 对此问题的回答中有更多详细信息。

I'm not very familiar with Twisted, but I'm not sure what you're trying to do is supported on Heroku. Heroku currently only supports HTTP[S] requests and not raw TCP. There are more details in the answers to this question.

如果您想连接到您的应用程序,则应使用 myapp.herokuapp.com 主机名或您添加的任何自定义域。

If you wanted to connect to your app, you should use the myapp.herokuapp.com host name or any custom domain that you've added.

这篇关于Heroku和扭曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆