Copy link to clipboard
Copied
Hi!
I need to send messages via sockets to Lr. The communincation between my client and netcat (as a server) goes well, the messages are sent. However, I can't get any messages in Lr. Based on the logs onConnecting, onConnection, onError and onClosed are triggered, but it looks likes onMessage is not. I've replicated this with my client and with netcat as a client.
The lua code is the following:
LrTasks.startAsyncTask(function()
LrFunctionContext.callWithContext( 'socket', function( context )
local running = true
local socket = LrSocket.bind {
functionContext = context,
plugin = _PLUGIN,
port = 19684,
mode = 'receive',
onMessage = function(socket, message)
outputToLog("Message!")
--Never happens
end,
onClosed = function (socket)
outputToLog("Closed")
running = false
end,
onError = function (socket, err)
socket:reconnect()
outputToLog("Error: " .. err)
end,
onConnecting = function( socket, port )
outputToLog("Waiting for connection on port " .. port)
end,
onConnected = function (socket, port)
outputToLog("New connection!")
end}
while running do LrTasks.sleep (0.1) end
socket:close ()
end )
end )
Do you guys have an idea?
Thanks!
OK, so I found the solution: all the messages must end with a new line (\n) otherwise they are not processed.
Copy link to clipboard
Copied
OK, so I found the solution: all the messages must end with a new line (\n) otherwise they are not processed.
Copy link to clipboard
Copied
Glad you sort it out.
That silly requirement was never documented, and Adobe has pretty much stopped maintaining the SDK, so there's little point in filing a bug.
If you search this forum for "LrSocket", you can find some previous threads with people discussing their experience, in case you get hung up again.
Copy link to clipboard
Copied
Thank you very much for sharing your answer