格式错误的HTTP请求

时间:2017-10-04 08:22:43

标签: vb.net laravel

我从服务器收到“格式错误的HTTP请求”的原因是什么?

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        ConnectAsync("ws://127.0.0.1:8000/api/setup/importwizard/checkUpdates/").Wait()
  End Sub

  Private Async Function ConnectAsync(uri As String) As Task
        Thread.Sleep(1000)

        Dim WebSocket As ClientWebSocket = Nothing

        Try

              WebSocket = New ClientWebSocket
              Await WebSocket.ConnectAsync(New Uri(uri), CancellationToken.None)

              'Await Task.WhenAll(ReceiveAsync(WebSocket), SendAsync(WebSocket))
              Await Task.WhenAll(ReceiveAsync(WebSocket))

        Catch ex As Exception
              Debug.WriteLine("Exception: {0}", ex.Message)
        Finally
              If WebSocket IsNot Nothing Then
                    WebSocket.Dispose()
              End If

              Debug.WriteLine(vbCrLf & "Websocket closed.")
        End Try
  End Function

来自服务器的响应

  

Laravel开发服务器在http://127.0.0.1:8000/启动   [Wed Oct 4 16:15:05 2017] 127.0.0.1:59590无效请求(格式错误的HTTP请求)

Response From Server

1 个答案:

答案 0 :(得分:0)

您必须使用 WebSocket 服务器 ws://127.0.0.1:8000

在这里,您使用的是 Laravel HTTP 服务器

改成这样:ws://127.0.0.1:6001

(这是默认端口,或更改为您当前使用的端口)