我在 .NET VB.NET 中有这些代码:
Dim serverIP As String = "172.16.1.24"
Dim localIP As String = "172.16.1.27-RMSDESKTOP"
Dim port As Integer = 55672
Dim apiAddr As String = "/api/queues/%2f/" & localIP & "/get"
Dim requestAddr As String = "http://" & serverIP & ":" & port & apiAddr
Debug.WriteLine(requestAddr)
wb = New System.Net.WebClient
While isConnect = True
Dim postBody As String = My.Settings.body1 '' it is correct json parameters
wb.Headers.Add("Content-Type", "application/json")
wb.Credentials = New System.Net.NetworkCredential("guest", "guest")
Dim result As String = wb.UploadString(requestAddr, "POST", postBody)
If result IsNot Nothing AndAlso result.Length > 0 Then
Debug.WriteLine(Now.ToString & ":" & "RESPONSE: " & result)
End If
'405 Method not allowed' and 'request was aborted'
当我使用 HTTP 类型获取 RabbitMQ 消息时发生错误。
有时发生'405 Method not allowed'
有时发生
'request was aborted' error.
我们的用户名、密码、端口、队列名称和服务器 ip 都是正确的。我使用'PUT'方法尝试但也发生错误-->:底层连接已关闭,无法从传输连接读取数据。
参考:
http ://hg.rabbitmq.com/rabbitmq-management/raw-file/rabbitmq_v3_0_1/priv/www/api/index.html