Skip to main content
benl13565393
Inspiring
June 18, 2017
Question

Listening to socket in Photoshop CC 2017

  • June 18, 2017
  • 2 replies
  • 1598 views

I'm running Photoshop CC 2017 and looking at potentially automating some processing through scripts which are run automatically. This is on a Mac. I've noticed that invoking scripts via command line are slow to start Ps or can't start it. I've tried launching it two ways: Via the Ps executable with the JSX script filename or trying to ext ESTK to launch it.

/Applications/Adobe\ Photoshop\ CC\ 2017/Adobe\ Photoshop\ CC\ 2017.app/Contents/MacOS/Adobe\ Photoshop\ CC\ 2017 "~/Documents/Adobe Scripts/test.jsx"

or

/Applications/Adobe\ ExtendScript\ Toolkit\ CC/ExtendScript\ Toolkit.app/Contents/MacOS/ExtendScript\ Toolkit -run "~/Documents/Adobe Scripts/test.jsx"

With the former, it will launch Ps, but for some reason I have to click on the opened window for Ps to fully start (it starts, but the window is solid dark gray indicating it is still loading and will remain in this state until I mouse click the window). With the latter, it does nothing.

Both are disappointing results to encounter. I then thought perhaps I could just build a server "in Photoshop" to take in commands and then do the things I need. I was looking at 2 avenues. Either via scripting or via the SDK. As scripting looked like it was quick to at least test, I started with that route.

What I find is that when I listen on the socket, it returns false, and hence never runs. I've cut and pasted the code provided by Adobe. Which is also the same or similar code from numerous other examples. I've tried various permutations of the Adobe code and other code I've seen on the net. There is really not much to the code.

The Adobe documentation I'm referring to is here: https://www.adobe.com/content/dam/Adobe/en/devnet/scripting/pdfs/javascript_tools_guide.pdf..

And I'm doing this:

conn = new Socket;
// listen on port 80
if (conn.listen (80)) {

// wait forever for a connection var incoming;
do incoming = conn.poll();
while (incoming == null);

// discard the request
conn.read();
// Reply with a HTTP header
incoming.writeln ("HTTP/1.0 200 OK");
incoming.writeln ("Content-Type: text/html");
incoming.writeln();
// Transmit a dummy homepage
incoming.writeln ("<html><body><h1>Homepage</h1></body></html>"); // done!
incoming.close();
delete incoming;

} else {

$.writeln("NOPE")

}

And I see the "NOPE" show up in the JavaScript Console in ESTK.

I did verify that using Socket with open works. So I know that I can connect via open and receive from a remote server. So it has dawned on me that perhaps Photoshop is blocking this. Note that I have various servers running locally on my machine. And none of those require any form of firewall adjustments. They just run (they are using non-standard ports).

I also tried to enable "Enable Remote Connections" from Preferences:Plug-Ins, but that doesn't seem to do anything.

Is there some setting that I need within Photoshop for this to work? Or does this no longer work? Or is there something else that needs to be done?

While I'm on this subject, is there a better way to do what I want? I more or less want to run certain known scripts on specific files. I'd ideally like our build server to trigger this (based on new versions of the files or perhaps even new files). So the ideal solution would seem to be either command line invocation or being able to have a "Photoshop Server" which can listen and then handle a request to do this.

Thanks!

This topic has been closed for replies.

2 replies

Participant
June 13, 2022

Same issue

Liran Tabib
Inspiring
February 3, 2021

Hi!

I'm having a similar issue with the listen() not working on Mac (on windows it works fine).

Did you manage to solve this?