Question about plugin socket communication
I have a question about LrSocket's receive process
startRecvHttpServer = function()
LrTasks.startAsyncTask(function()
LrFunctionContext.callWithContext("sign_in", function(context)
local running = true
local serverSocket = LrSocket.bind({
functionContext = context,
plugin = _PLUGIN,
port = 9999,
mode = "receive",
onConnecting = function(socket, port)
end,
onConnected = function(socket, port)
end,
onError = function(socket, errorMsg)
end,
onMessage = function(socket, data)
logger.Info("Receive Callback: " .. data)
running = false
end,
onClosed = function(socket)
running = false
end,
})
while running do
LrTasks.sleep(1 / 2)
end
serverSocket:close()
end)
end)
end
The following code makes localhost:9999 wait to receive a message.
In this state, type http://locahost:9999/xxx in the address bar of the browser and onMessage will be called. This is the expected behavior, but strangely enough, the plugin sends “ok” data to the browser on its own.
The following is the actual data sent as filtered by Wireshark.
---
0000 02 00 00 00 45 00 00 2c c2 37 40 00 80 06 00 00 ....E..,.7@.....
0010 7f 00 00 01 7f 00 00 01 27 0f c5 26 41 40 24 1c ........'..&A@$.
0020 db 9c 2d 1d 50 18 27 f9 b3 0b 00 00 6f 6b 0d 0a ..-.P.'.....ok..
---
This behavior is not expected. The browser raises ERR_INVALID_HTTP_RESPONSE when it receives “ok
Why does the plugin send “ok”?
I would like to know if this is a bug or a specification.
