exciting-io / printer

Tools for exploring the possibilities of "internet of things" printing.
http://exciting.io/printer
MIT License
481 stars 94 forks source link

Connecting the printer via a Proxy #45

Closed Megabouda closed 5 years ago

Megabouda commented 11 years ago

Hi, First of all thanks a lot for making all this work open-source ! I'm planning on making a small box, receiving messages and printing them in a drawer, like a insta-mailbox on your desk, and your project is very helpful.

I've got an issue connecting the printer to the internet. I'm hacking from a University and the connection here is protected by a proxy. After some extensive research, I found tips on how to bypass the proxy: http://goo.gl/dnWhNl

So I tried to modify your code following the tips:

debug2("Attempting to connect to ", host); if (client.connect("proxy.noc.titech.ac.jp", 3128)) { // the proxy URL and its port digitalWrite(downloadLED, HIGH); client.print("GET printer.gofreerange.com"); client.print("/printer/"); client.print(printerId); client.println(" HTTP/1.0"); client.print("Host: "); client.print(host); client.print(":"); client.println(port); client.flush(); client.print("Accept: printer.gofreerange.com/application/vnd.freerange.printer."); client.println(printerType); client.print("X-Printer-Version: "); client.println(sketchVersion); client.println(); boolean parsingHeader = true;

The output is: the yellow led turns on for 5 seconds, then turns off and the red led flashes 5 times. Then all the leds are off for 10 seconds. The printer is not detected on: http://printer.gofreerange.com/my-printer

My question is, do you guys know if there are other parts of the code that should be modified?

Thank you ! Pierre

lazyatom commented 11 years ago

Five flashes indicates a 'recoverable error' (i.e. an error during connection to the network). I haven't tried connecting via a proxy, but I don't think there should be any other parts of the code that need to be changed. According to this thread on the Arduino forums it should be possible -- one difference between your code and theirs is that they include the http in the final hostname, i.e.

client.print("GET http://printer.gofreerange.com"); client.print("/printer/"); // etc....

Maybe try that?

Megabouda commented 11 years ago

Thank you for the answer ! I tried adding the http:// but it still doesn't connect correctly.

I tried this code: https://gist.github.com/Megabouda/6496176

Basically changing the GET line.

And here is my Serial output: 9071499: ID: 7m1j0q4t2a8p4v0i 3086: IP: 192.168.11.8 3098: Attempting to connect to printer.gofreerange.com connected to proxy 4585: Waiting for data 4585: Waiting for data 4586: Waiting for data 4606: Waiting for data 4632: Waiting for data 4657: Waiting for data 4682: Waiting for data 4707: Waiting for data 4731: Waiting for data 4757: Waiting for data 4782: Waiting for data 4806: Waiting for data 4832: Waiting for data 4856: Waiting for data 7931: Content length: 0 8931: Waiting for data ... 517133: Server disconnected 517164: Response code != 200 518194: Bytes: 0 518195: Duration: 121041

The yellow led is on for several minutes and then 5 flashes.. Any Ideas? I'm still pretty much stuck. :l Thank you for helping !!

Megabouda commented 11 years ago

If someone can help, please do :). Thank youu

lazyatom commented 11 years ago

Can you set your printer running and attempting to connect? I'd like to try monitoring the server to see if I can see any connections.

It's also worth bearing in mind that you can run your own copy of the backend server somewhere that isn't behind your proxy, if it turns out that this hurdle is insurmountable...

-- James

On Wednesday, 11 September 2013 at 20:48, Megabouda wrote:

If someone can help, please do :). Thank youu

— Reply to this email directly or view it on GitHub (https://github.com/freerange/printer/issues/45#issuecomment-24289808).

lazyatom commented 11 years ago

Also, can you paste the output of running this command from a computer which is also configured behind the same proxy?

curl -v -H "Accept: application/vnd.freerange.printer.A2-raw" -H "X-Printer-Version: 1.0.5" -X GET "http://printer.gofreerange.com/printer/megabouda-test HTTP/1.0"