Vb.net-流读取器在读取HTTP侦听器的输入流时引发错误

时间:2019-05-24 10:38:19

标签: vb.net webserver

我有一个奇怪的错误。

我分别在网络服务器上处理gat数据-我正在运行网络服务器,并从外部组件通过post参数获取数据。

邮件中确实包含以base64编码的图像。

没有图像,一切都会按预期工作-但是,有了图像,在大约30%的按摩中我确实出错了。

enter image description here

是导致错误的流读取器。基本上说功能无效。

这是整个功能:

Public Sub MyCollectFromTriggerInterface()


    Main.MessageObj.MyMessage("DLVPDataCollector: ", "Start thread for DLVP collection. (Trigger Interface)", 3)
    Main.LogObj.MsgLog("ClassDLVPDataCollector", "MyCollectFromTriggerInterface", "Start thread for DLVP collection. (Trigger Interface)")

    'Falls das Betriebssytem den Server nicht 
    If Not System.Net.HttpListener.IsSupported Then
        Main.MessageObj.MyMessage("DLVPDataCollector: ", "!!! Windows XP SP2, Server 2003, or higher is required to use the HttpListener class !!!", 3)
        Main.LogObj.ErrLog("ClassDLVPDataCollector", "MyCollectFromTriggerInterface", "Windows XP SP2, Server 2003, or higher is required to use the HttpListener class.")
        Exit Sub
    End If

    'Den Listener starten.
    Dim listener As System.Net.HttpListener = New System.Net.HttpListener()
    Dim adr As String = Main.LoadSettingsObj.Settings_DlvpDatacollector_HTTPServerAddress_TriggerInterface
    listener.Prefixes.Add(adr)
    listener.Start()
    Main.MessageObj.MyMessage("DLVPDataCollector: ", "Listener started. (Trigger Interface)", 3)
    Main.LogObj.MsgLog("ClassDLVPDataCollector", "MyCollectFromTriggerInterface", "Listener started. (Trigger Interface)")

    While True

        'Wenn die Applikation beendet werden soll.
        If Main.EndApplication = True Then
            Main.MessageObj.MyMessage("DLVPDataCollector: ", "Stop thread for DLVP collection. (Trigger Interface)", 3)
            Main.LogObj.MsgLog("ClassDLVPDataCollector", "MyCollectFromTriggerInterface", "Stop thread for DLVP collection. (Trigger Interface)")
            Exit While
        End If

        'Auslesen, was der Client gesendet hat.
        Dim response As HttpListenerResponse = Nothing
        Dim context As HttpListenerContext = listener.GetContext()
        Dim PostParameter = New StreamReader(context.Request.InputStream).ReadToEnd()

        'Neuen Thread starten.
        Dim obj As New ArgumentsTo_MyDoWorkflowTI
        obj.Data = PostParameter
        Dim t As New Threading.Thread(AddressOf MyDoWorkflowTI)
        t.IsBackground = True
        t.Start(obj)

        'Antwort an den Client senden.
        Dim b As Byte() = Encoding.UTF8.GetBytes("ACK")
        context.Response.StatusCode = 200
        context.Response.KeepAlive = False
        context.Response.ContentLength64 = b.Length
        Dim output = context.Response.OutputStream
        output.Write(b, 0, b.Length)
        context.Response.Close()

    End While

End Sub

我想这与消息的长度或某些超时问题或其他有关...

有人有主意吗?

该界面每秒最多可获取4次数据。

K,

安德烈亚斯

这是该例外的详细信息:

enter image description here

0 个答案:

没有答案