Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


[SDK] Can't receive messages with LrSocket

Community Beginner ,
Nov 03, 2021 Nov 03, 2021

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!

TOPICS
SDK

Views

31

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Nov 03, 2021 Nov 03, 2021
OK, so I found the solution: all the messages must end with a new line (\n) otherwise they are not processed.

Likes

Translate

Translate
Community Beginner ,
Nov 03, 2021 Nov 03, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

LATEST

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.

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines