在端口8080的DNS缓存中找不到主机名,但在端口80上没有找到主机名?

时间:2017-03-30 17:28:06

标签: spring curl dns raspberry-pi

我正在测试我在笔记本电脑上使用Springboot创建的API(192.168.1.217:8080),我试图通过SSH从我的Raspberry Pi获取cURL请求。

当我尝试通过端口8080发送请求时,我收到的错误似乎不一样:

 Sub Consolidate_BST()

 Dim SummarySheet As Worksheet
 Dim FolderPath As String
 Dim NRow As Long
 Dim FileName As String
 Dim WorkBk As Workbook
 Dim sourceRange As Range
 Dim destrange As Range

 Worksheets("Consolidate BSts").Range("A1:J50000").ClearContents
 Application.AskToUpdateLinks = False
 Application.DisplayAlerts = False
 ' Create a new workbook and set a variable to the first sheet.
 Set SummarySheet = ThisWorkbook.Sheets("Consolidate BSts")

 ' Modify this folder path to point to the files you want to use. 'M
 FolderPath = "C:\Users\413315\Documents\\March Bluesheets"

 ' NRow keeps track of where to insert new rows in the destination workbook.
 NRow = 1

 ' Call Dir the first time, pointing it to all Excel files in the folder path.
 FileName = Dir(FolderPath & "*.xl*")

 ' Loop until Dir returns an empty string.
 Do While FileName <> ""
 ' Open a workbook in the folder
 Set WorkBk = Workbooks.Open(FolderPath & FileName)

 ' Set the cell in column A to be the file name.
 SummarySheet.Range("A" & NRow).Value = FileName

 ' Modify this range for your workbooks.
 ' It can span multiple rows.
 Set sourceRange = WorkBk.Worksheets("Regional Estimates").Range("B3:J1000")

 ' Set the destination range to start at column B and
 ' be the same size as the source range.
 Set destrange = SummarySheet.Range("B" & NRow)
 Set destrange = destrange.Resize(sourceRange.Rows.Count, _
 sourceRange.Columns.Count)

 ' Copy over the values from the source to the destination.
 destrange.Value = sourceRange.Value

 ' Increase NRow so that we know where to copy data next.
 NRow = NRow + destrange.Rows.Count

 ' Close the source workbook without saving changes.
 WorkBk.Close savechanges:=False

 ' Use Dir to get the next file name.
 FileName = Dir()
 Loop


 SummarySheet.Columns.AutoFit
 Worksheets("Consolidate BSts").Range("D2:D50000").ClearContents


 End Sub 

然而,cURL适用于相同的IP但使用端口80:

pi@raspberrypi:~ $ curl -v 192.168.1.217:8080/api
* Hostname was NOT found in DNS cache
*   Trying 192.168.1.217...

我试过环顾四周但无济于事...有人为什么我在DNS缓存中找不到自己的主机名有任何建议?

干杯

2 个答案:

答案 0 :(得分:1)

没有协议前缀的卷曲假定HTTP端口80.

要使用另一个端口,它没有做出这个假设,您需要做的就是将命令的URL更改为:

curl -v http://192.168.1.217:8080/api

这是一篇关于这个主题的好文章:Using CURL For Testing Web Applications

答案 1 :(得分:1)

不,Hostname was NOT found in DNS cache不是问题。您可以在下一行的两个示例中清楚地看到,在说curl正在尝试连接到192.168.1.217之后。您的问题是该IP地址上没有任何东西在端口8080上应答(当Apache服务器 在端口80上应答时)。

如果你得到一个很长的停顿然后超时而不是快速的“拒绝连接”,你几乎肯定需要在服务器机器的本地防火墙上打开端口8080。