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

Issue connecting to listener using LrSocket send

New Here ,
Mar 17, 2024 Mar 17, 2024

Copy link to clipboard

Copied

I am creating an LR plugin to commuicate with my macOS app and am using LrSocket.

 

So far, I have successfully created the LrSocket to receive, but I am unable to get the send client to connect.

 

I am using a different port for each of them and am testing with the sample code provided by Adobe in the documentation as under:

 

local LrFunctionContext = import "LrFunctionContext"
local LrTasks = import 'LrTasks'
local LrSocket = import 'LrSocket'
local LrDialogs = import 'LrDialogs'

LrTasks.startAsyncTask( function()
LrFunctionContext.callWithContext( 'socket_remote', function( context )
local running = true
local sender = LrSocket.bind {
functionContext = context,
plugin = _PLUGIN,
port = 1235,
mode = "send",
onConnecting = function( socket, port )
LrDialogs.message("Connecting")
end,
onConnected = function( socket, port )
sender:send( "Hello world\n" )
LrDialogs.message(port)
end,
onMessage = function( socket, message )
end,
onClosed = function( socket )
running = false
end,
onError = function( socket, err )
if err == "timeout" then
socket:reconnect()
end
end,
}
sender:send( "Hello world\n" )
while running do
LrTasks.sleep( 1/2 ) -- seconds
end
sender:close()
end )
end )​

 

 

 

I am using netcat command in terminal to set up a listener:
nc -l 1236
 

 

 

The LrSocket just gets stuck on Connecting before timing out.

 

Can someone please guide as to what is going wrong?

TOPICS
macOS , SDK

Views

179

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
Engaged ,
Mar 17, 2024 Mar 17, 2024

Copy link to clipboard

Copied

It might be worth your while to look at URLHandler for talking to lightroom. I found the whole process a bunch easier than sockets. There's a reasonably good description in the SDK programmer's guide and Jeffrey Friedl fills in some fo the gaps hear: http://regex.info/blog/2012-01-17/1926.

 

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 ,
Mar 18, 2024 Mar 18, 2024

Copy link to clipboard

Copied

I've never used LrSocket, but there are other threads here from developers describing how they got it to work (or not):

https://community.adobe.com/t5/forums/searchpage/tab/message?filter=location&q=LrSocket&noSynonym=fa...

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
Engaged ,
Mar 18, 2024 Mar 18, 2024

Copy link to clipboard

Copied

LATEST

It's a pain, nearly everybody has problems with it to start. My main beef is that it forces you to send on one port, receive on another and you end up jumping through hoops trying to get the two to work together. URLHandler is much, much simpler. I suspect the performance may not be as good as sockets but for most of what I'm doing here it's working well and it makes it very easy to talk to apps like Bear and Obsidian. I'm currently using it with Bear to link collections to production notes.

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