I've been using an Extendscript for years now that scrapes a website and brings some of its data into Photoshop. I use the Socket object to talk to the server. The problem I'm trying to solve right now is how to do this through a firewall on a corporate network...if I try this script through the firewall Photoshop simply freezes when I try the socketObj.open() command.
Anyone worked with this? It would even be an improvement to error trap it so Photoshop doesn't freeze, and I could tell the user to try another network.
I understand that the Socket Object is very limited in Extenscript, but I'm not an expert in TCP or firewalls, so I don't have too deep an understanding of it.
Thanks!
Does the Socket Object work through firewalls?
-
- Posts: 8
- Joined: Tue Oct 11, 2016 10:12 am
-
- Posts: 8
- Joined: Tue Oct 11, 2016 10:12 am
Re: Does the Socket Object work through firewalls?
I've learned that the corporate network uses a PAC (Proxy Auto-Config) file to gain access to the web, and if I use the URL to this file as a host for the Socket Object, I get a connection. Not sure how to get to other URLs, though.
-
- Posts: 8
- Joined: Tue Oct 11, 2016 10:12 am
Re: Does the Socket Object work through firewalls?
For the time being I'm throwing up an error to switch networks, which is better than Photoshop freezing. Wish I had the knowledge to reach the URL I want through the proxy, though.
-
- Posts: 8
- Joined: Tue Oct 11, 2016 10:12 am
Re: Does the Socket Object work through firewalls?
OK, I think I got this working and have a better understanding.
If you’re going through a proxy you first have to set up a TCP/IP ’tunnel’ through the proxy server, using the HTTP request method ‘CONNECT’ (instead of ‘GET’). If you get the reply like
from the proxy server then you can send the usual ‘GET’ request using the Socket object you’ve opened the connection with.
In my case I also had to use port 8080, so the first request to the proxy server is
[actual site name withheld] and then:
I then write the full reply to an external file and then extract the parts of the web page I need.
If you’re going through a proxy you first have to set up a TCP/IP ’tunnel’ through the proxy server, using the HTTP request method ‘CONNECT’ (instead of ‘GET’). If you get the reply like
Code: Select all
HTTP/1.1 200 Connection established
In my case I also had to use port 8080, so the first request to the proxy server is
Code: Select all
socket.write("CONNECT proxy.sitename.com:8080 HTTP/1.0\n\n")
Code: Select all
socket.write("GET http://www.site.com HTTP/1.0\n\nHost:www.site.com\n\nConnection: close\n\n\n\n")