java - 在 Heroku 中部署爬虫并获取 java.net.SocketTimeoutException: Read timed out
问题描述
我编写了一个快速应用程序,它转到一个 URL 并检查一些信息,它在我的本地工作得很好,但是当我部署到 Heroku 时,它会引发以下异常:
PS:我使用 HTMLUnit
021-02-15T04:47:07.740845+00:00 app[web.1]: java.net.SocketTimeoutException: Read timed out
2021-02-15T04:47:07.741156+00:00 app[web.1]: at java.net.SocketInputStream.socketRead0(Native Method)
2021-02-15T04:47:07.741208+00:00 app[web.1]: at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
2021-02-15T04:47:07.741246+00:00 app[web.1]: at java.net.SocketInputStream.read(SocketInputStream.java:171)
2021-02-15T04:47:07.741285+00:00 app[web.1]: at java.net.SocketInputStream.read(SocketInputStream.java:141)
2021-02-15T04:47:07.741326+00:00 app[web.1]: at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
2021-02-15T04:47:07.741398+00:00 app[web.1]: at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
2021-02-15T04:47:07.741458+00:00 app[web.1]: at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
2021-02-15T04:47:07.741522+00:00 app[web.1]: at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
2021-02-15T04:47:07.741591+00:00 app[web.1]: at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
2021-02-15T04:47:07.741650+00:00 app[web.1]: at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
2021-02-15T04:47:07.741717+00:00 app[web.1]: at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
2021-02-15T04:47:07.741758+00:00 app[web.1]: at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
2021-02-15T04:47:07.741802+00:00 app[web.1]: at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
2021-02-15T04:47:07.741845+00:00 app[web.1]: at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
2021-02-15T04:47:07.741885+00:00 app[web.1]: at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
2021-02-15T04:47:07.741914+00:00 app[web.1]: at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
2021-02-15T04:47:07.741949+00:00 app[web.1]: at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
2021-02-15T04:47:07.741993+00:00 app[web.1]: at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
2021-02-15T04:47:07.742026+00:00 app[web.1]: at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
2021-02-15T04:47:07.742064+00:00 app[web.1]: at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
2021-02-15T04:47:07.742107+00:00 app[web.1]: at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:192)
2021-02-15T04:47:07.742149+00:00 app[web.1]: at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1545)
2021-02-15T04:47:07.742190+00:00 app[web.1]: at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1468)
2021-02-15T04:47:07.742228+00:00 app[web.1]: at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:462)
2021-02-15T04:47:07.742266+00:00 app[web.1]: at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:382)
2021-02-15T04:47:07.742303+00:00 app[web.1]: at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:539)
2021-02-15T04:47:07.742358+00:00 app[web.1]: at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:520)
解决方案
推荐阅读
- javascript - javascript 控制台中的正则表达式。注销字符而不是整个模式
- python - 如何在 python 中使用文件路径作为输出中的列从 excel 文件中读取数据
- node.js - 无法在 webdriverio Cucumber 框架中为表单字段设置值
- javascript - react-native 如何在路由参数中分配默认值
- sql - SQL - 尝试通过加入日期维度表来创建每日日志
- c# - C# 通过套接字发送字节数组
- reactjs - 在另一个函数中创建一个函数来改变状态
- java - 为什么更改 VMOptions 后无法打开 Android Studio
- python - FFT 似乎没有返回正确的结果
- xml - 如何从 Ansible 中的 xml 响应中读取和检索多个值