10 Replies Latest reply on Mar 7, 2017 11:52 AM by Vinícius Amaral

    Socket object

    Vinícius Amaral Level 1

      Hello there

      I´m trying to learn how to connect the InDesign with a web page for a future project.

      Now I´m using the sample code released for Adobe at the JavaScript Tools Guide, but all my tries was unsuccessful.

      I cold not connect with any page, server and bla, bla, bla.

      Check the below code (exactly as in Adobe reference document)


      reply = "";
      conn = new Socket;
      // access Adobe’s home page
      if (conn.open ("www.adobe.com:80")) {
      // send a HTTP GET request
      conn.write ("GET /index.html HTTP/1.0\n\n");
      // and read the server’s reply
      reply = conn.read(999999);


      Anyone can help me?


      PS.: I´ve read a lot of topcs, articles and tutorials about this subject and all my tests was unsucessful.

        • 1. Re: Socket object
          Loic.Aigon Adobe Community Professional

          I could never get it to myself to work neither but I think I read other fellows around did so it's likely you should find some snippets already in the forum.

          FWIW, the only times i had to retrieve data from http,I used getUrl from Rorohiko, it works like a charm:

          Rorohiko: July 2008





          • 2. Re: Socket object
            Laubender Adobe Community Professional & MVP

            Hi Vinicius,

            see also this thread where several methods are discussed:

            Is it possible to load web content?


            FWIW and it might not apply in your case:

            For downloading e.g. an image from a dropbox account I had success with a combined AppleScript/ExtendScript method using curl services that are implemented with OSX.



            1 person found this helpful
            • 3. Re: Socket object
              Ronald63 Level 4



              Try this snippet (not working with "www.adobe.com")


              var conn = new Socket;
              var host =  "www.indesignjs.de";
              var cmd = "GET /index.html HTTP/1.1\r\nHost:"+host+"\r\n\r\n";
              var reply='';
              conn.timeout = 100;
              if (conn.open (host +':80', 'BINARY')) {
                      conn.write (cmd);
                      while (conn.connected && ! conn.eof) {
                         reply += conn.read(1024) + "\n";

              Good luck ;-)

              • 4. Re: Socket object
                Vinícius Amaral Level 1

                Dear Loic.Aigon


                First of all, thanks for your attention.

                I've seen before a lot of designners/programmers getting successful tests with this snnipet code that you mentioned. I think if I try, I will also could.

                I wish do something with the Socket object, but if I couldn´t I will use the Rorohiko tools.


                Thanks a lot

                • 5. Re: Socket object
                  Vinícius Amaral Level 1

                  Hi Laubender


                  I just need to access a TXT or XML file.

                  I believe the Rorohiko solution works fine, but I wanna know why the Adobe´s solution doesn´t.

                  If I could not fix this issue I will use the Rorohiko.


                  Best regards

                  • 6. Re: Socket object
                    Vinícius Amaral Level 1

                    Hello Ronald


                    I´ve tryed to use your code, but the variable returns me nothing.


                    Have you returned anything?

                    When I check the connection, it retuns me false



                    It is an official document from Adobe.

                    I can´t believe it not will gonna work.



                    • 7. Re: Socket object
                      Ronald63 Level 4



                      I get a reply ... (Testing with MacOS 10.12.3 - InDesign CC2014).

                      If you are on Windows, maybe a problem with the anti-virus or firewall.

                      • 8. Re: Socket object
                        Laubender Adobe Community Professional & MVP

                        I can confirm what Ronald says.
                        I'm on Mac OSX using InDesign CC 2017 and ran the script snippet from the ESTK.


                        It returned:


                        HTTP/1.1 200 OK
                        Date: Sat, 04 Mar 2017 13:00:35 GMT
                        Server: Apache/2.4.18 (Ubuntu)
                        Last-Modified: Thu, 30 Jul 2015 11:55:00 GMT
                        ETag: "e3-51c165f764d00"
                        Accept-Ranges: bytes
                        Content-Length: 227
                        Vary: Accept-Encoding
                        Content-Type: text/html
                        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
                        <html><head><meta http-equiv=Refresh content="0;url=/auflage2/"></head>
                        <a href="auflage2/index.php">2. Auflage InDesign automatisieren</a>


                        Seems the file is by Gregor Fellenz.



                        • 9. Re: Socket object
                          Vinícius Amaral Level 1

                          Hi Ronald


                          Thanks for your help.

                          I also have one Mac and it is working,

                          Now I have to figure out why is not working on PC in my companny.

                          I don't think it is because a possible firewall.

                          I will keep in contact.

                          • 10. Re: Socket object
                            Vinícius Amaral Level 1

                            Perfect Laubender


                            Now I have a new task...

                            Why it is not working on my PC.

                            I will get an other internet link and try it again.


                            Thanks for your attention.