• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

[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

159

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.

Votes

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.

Votes

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

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.

 

 

Votes

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
New Here ,
Apr 07, 2024 Apr 07, 2024

Copy link to clipboard

Copied

LATEST

Thank you very much for sharing your answer

Votes

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