Skip to main content
bduffy323
Inspiring
February 7, 2014
Question

socket connection not returning/reading response

  • February 7, 2014
  • 1 reply
  • 4931 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:
Legend
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

Trevor:
Legend
February 20, 2014

Hi bduff323

Sorry I can't help you.

All I can say is that I had a lot of problem without the script to get info from the web to indesign but with the script I have had no problems at all of sending or receiving data to a remote server on the web on both Windows and Mac.

Maybe send Kris an invite (PM or email) to the tread to see if he can help you out.

Trevor