Skip to main content
bduffy323
Inspiring
February 7, 2014
Question

socket connection not returning/reading response

  • February 7, 2014
  • 1 reply
  • 4905 views

Env: Indesign CS 5.5 and Indesign CS 6; Mac OS 10.8.4

I have a strange issue with reading the response from the server that just started after a client upgraded from a previous OS to Mac OS 10.8.4. However, this particular script has worked on other 10.8.4 machines so I believe it is another issue.

Here is the code in question:

var rtnData = "";

conn = new Socket;

if (File.fs == "Windows") var isMac=0;

          else var isMac=1;

var myRequest = "GET "+vSubDir+"/get_Pathnames.asp?ismac="+isMac+" HTTP/1.0\n\n";

 

if (debug) $.writeln(myRequest);

   

if (conn.open (vHost))

{       

       

        conn.write (myRequest);       // send a HTTP request

        rtnData = conn.read(999999);  // and read the server’s reply

       

        conn.close();

}

vHost=I.P address of server

vSubDir=subdirectory to the file

So some of the tests I ran already:

conn.open(vHost) returns true.

When I go to vHost+vSubDir+"/get_Pathnames.asp?ismac="+isMac+" directly in the browser I receive the response I expect.

Essentially Indesign is connecting to the server but not reading the response that I know exists. Has anyone else experienced this issue or something similiar? I can't recreate it anywhere but the client's machine.

This topic has been closed for replies.

1 reply

Trevor:
Braniac
February 11, 2014
Participating Frequently
February 20, 2014

edit: The client has sent me a 10.8.5 OS laptap to test with and it does not work on this Mac either.

Hey Trevor. So I downloaded thes script and tried making the socket call using the GetURL() method. Still I get no response. I decided to step through what the script was doing and it looks like it is an infinite loop because I really am getting no response. The script gets all the way down to this line:

readState.dataAvailable = readState.buffer.length > 0;

which returns false and then we go back through the loop.

So this is the request that the getURL() function is using to open the socket with where the parsedURL.path and parsedURL.address are correct and are the same as being using in the browser to connect:

        "GET /" + parsedURL.path + " HTTP/1.0\n" +

        "Host: " + parsedURL.address + "\n" +

        "User-Agent: InDesign ExtendScript\n" +

        "Accept: text/xml,text/*,*/*\n" +

        "Accept-Encoding:\n" +

        "Connection: keep-alive\n" +

        "Accept-Language: *\n" +

        "Accept-Charset: utf-8\n\n";

Not sure if it helpful but the response headers are as follows:

  1. HTTP/1.1 200 OK Cache-Control: private
  2. Content-Type: text/html
  3. Content-Encoding: gzip
  4. Vary: Accept-Encoding
  5. Server: Microsoft-IIS/8.5 Date: Thu, 20 Feb 2014 18:09:14 GMT
  6. Content-Length: 216

I get the headers by browsing to the URL in the browser. Can anyone think of any other avenues to look at?

EDIT #2 POST request also do not return any data. After executing the following code the reply is blank.

  

if (conn.open(vHost))

{

       

    conn.write("POST " +vSubDir+"/get_pathnames.asp HTTP/1.1\r\n");

    conn.write("Host: " + vHost + "\r\n");

    conn.write("Content-Length: " + data_string.length + "\r\n");

    conn.write("Content-Type: application/x-www-form-urlencoded\r\n");

    conn.write("\r\n");

   

    conn.write(data_string);

    var reply = "";

    reply = conn.read(999999);

    conn.close();

   

    if (debug) $.writeln("\n----------- return from pathnames -------------\n");

    if (debug) $.writeln(reply);

    if (debug) $.writeln("\n----------- return from pathnames END -------------\n");

}


Message was edited by: bduff323

Inspiring
February 24, 2014

Hi Kris, thanks for jumping in the discussion.

I took your advice and downloaded wireshark. I've only used it once before back in college so I'm not terribly familiar with it. What I did was just use the default capture options and start capturing. I then ran a script for a test socket call. I was expecting to see a http protocol packet from my IP to the server IP, however I did not. Any suggestions? The firewall is turned off.

To anyone else who views this thread that is running 10.8.5, if you can download and run the script on the sample document in http://www.rorohiko.com/podcast/geturl.zip and see if the images get filled in that would at least narrow it down to something specific to my machine/network.


Hi BDuff,

I don't have an installed 10.8.x any more - I have a few 10.6, and the rest is 10.9 - so I cannot try that out. I gave 10.9 + InDesign CC a quick test, and that all seems to work fine.

But it sounds odd - my hunch is that there is a problem with your setup. Things I'd try:

* If the user is not an admin user, try again as an admin user

* Go and check the various logs on the machine - there might be interesting tidbits there. /var/log/system.log for example

* Create a brand new admin user account, log in as that user, and try again. If that works, reset your ID prefs.

* Run Disk Utility on startup (if I remember correctly, hold Command-R on startup) and verify/repair disk and permissions

* Make sure there is no confusion with multiple network adapters (e.g. Wifi vs. wired ethernet). With Wireshark it's easy to pick the wrong adapter and see nothing useful. Turn off any network adapters not relevant to the exercise via the System Preferences

Cheers,

Kris