大家好,我想找一个人,直到我,如果我所做的是正确的或不正确的,我想要做的是在heroku中部署spring引导,并从python (烧瓶)框架中获得数据,我在我的设备中本地运行它,在我的设备中一切都很好,但是当尝试在heroku运行spring引导时,我得到了这个错误at=error code=H12 desc="Request timeout" method=GET path="/hi" host=java-be.herokuapp.com request_id=454eaa9f-b9e3-4c03-9e7d-4bf5b6c450a9 fwd="5.45.134.17" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=http。
这个错误显示在heroku日志中:
org.springframework.web.client.ResourceAccessException:
I/O error on GET request for "http://192.168.43.142:5000/":
Connection timed out (Connection timed out); nested exception
is java.net.ConnectException:
Connection timed out (Connection timed out)我的弹簧引导代码:
@GetMapping("/")
String home() throws URISyntaxException {
try {
RestTemplate restTemplate = new RestTemplate();
String url = "http://192.168.43.142:5000/"; // flask local host url
String helloWorld= restTemplate.getForObject(url, String.class);
SimpleClientHttpRequestFactory rf =(SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
rf.setReadTimeout(1000);
rf.setConnectTimeout(1000);
return helloWorld;
} catch (Exception e) {
e.printStackTrace();
}
return "";
}这是我的酒瓶代码:
from flask import Flask
from waitress import serve
app = Flask(__name__)
@app.route('/', methods=['GET'])
def home():
return "hello world"
if __name__ == '__main__':
try:
from waitress import serve
serve(app, host="0.0.0.0", port="5000")
except:
print("unexpected error")此外,当我在本地运行heroku服务器时,它也可以正常工作。
发布于 2021-12-18 14:31:19
您是否已经配置了武装包来部署在heroku上?
pip3 install flask gunicorn并创建Procfile文件并添加:
web: gunicorn wsgi:app按照链接到如何部署:https://dev.to/techparida/how-to-deploy-a-flask-app-on-heroku-heb
https://stackoverflow.com/questions/70404204
复制相似问题