{"action":"created","issue":{"url":"https://api.github.com/repos/ntruchsess/arduino_uip/issues/156","repository_url":"https://api.github.com/repos/ntruchsess/arduino_uip","labels_url":"https://api.github.com/repos/ntruchsess/arduino_uip/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/ntruchsess/arduino_uip/issues/156/comments","events_url":"https://api.github.com/repos/ntruchsess/arduino_uip/issues/156/events","html_url":"https://github.com/ntruchsess/arduino_uip/issues/156","id":156757247,"number":156,"title":"WebClient only works occasionally","user":{"login":"HoffaSweden","id":7819006,"avatar_url":"https://avatars.githubusercontent.com/u/7819006?v=3","gravatar_id":"","url":"https://api.github.com/users/HoffaSweden","html_url":"https://github.com/HoffaSweden","followers_url":"https://api.github.com/users/HoffaSweden/followers","following_url":"https://api.github.com/users/HoffaSweden/following{/other_user}","gists_url":"https://api.github.com/users/HoffaSweden/gists{/gist_id}","starred_url":"https://api.github.com/users/HoffaSweden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HoffaSweden/subscriptions","organizations_url":"https://api.github.com/users/HoffaSweden/orgs","repos_url":"https://api.github.com/users/HoffaSweden/repos","events_url":"https://api.github.com/users/HoffaSweden/events{/privacy}","received_events_url":"https://api.github.com/users/HoffaSweden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-05-25T13:56:24Z","updated_at":"2016-11-08T10:11:24Z","closed_at":null,"body":"Hello\n\nI'am trying to get an arduino webclient code to work. I am trying to fetch www.google.com\n\nMy issue is: It only works **occasionally**, lets say 1 time out of 5.\n4 times out of 5 it times out and says \"connection failed.\"\n\nI am using an arduino UNO and ENC28J60 marked: ENC28J60-I/SO e3, 1246A7S\nI am using arduino ide 1.5.8 and UIPethernet 1.59\n\nWhat can be wrong? I have tried the following / I know the following:\n\n-Level translator on 3,3V data pin from ENC28J60 to arduino. No difference at all.\n-Turned on debugging and sees that ARP runs.\n\nThis is my sketch, and further below the response code when functioning and failing\n\n```\n\n#include <SPI.h>\n#include <UIPEthernet.h>\n\n\nEthernetClient client;\n\nvoid setup() {\n\n  Serial.begin(9600);\n  while (!Serial) {\n    ; // wait for serial port to connect. Needed for native USB port only\n  }\n\n  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };\n  char server[] = \"www.google.com\";\n  IPAddress ip(192, 168, 77, 177);\n  Ethernet.begin(mac);\n\n  Serial.print(\"localIP: \");\n  Serial.println(Ethernet.localIP());\n  Serial.print(\"subnetMask: \");\n  Serial.println(Ethernet.subnetMask());\n  Serial.print(\"gatewayIP: \");\n  Serial.println(Ethernet.gatewayIP());\n  Serial.print(\"dnsServerIP: \");\n  Serial.println(Ethernet.dnsServerIP());\n\n  delay(1000);\n  Serial.println(\"connecting...\");\n\n  // if you get a connection, report back via serial:\n  if (client.connect(server, 80)) {\n    Serial.println(\"connected\");\n    // Make a HTTP request:\n    client.println(\"GET /search?q=arduino HTTP/1.1\");\n    client.println(\"Host: www.google.com\");\n    client.println(\"Connection: close\");\n    client.println();\n  } else {\n    // if you didn't get a connection to the server:\n    Serial.println(\"connection failed\");\n  }\n}\n\nvoid loop() {\n  // if there are incoming bytes available\n  // from the server, read them and print them:\n  if (client.available()) {\n    char c = client.read();\n    Serial.print(c);\n  }\n\n  //Serial.print(\"-\"); \n\n  // if the server's disconnected, stop the client:\n  if (!client.connected()) {\n    Serial.println();\n    Serial.println(\"disconnecting.\");\n    client.stop();\n\n    // do nothing forevermore:\n    while (true) {\n       //Serial.print(\"EL\"); \n    }\n  }\n}\n\n```\n\n```\n\n***************** serial print out when functioning\n\nlocalIP: 192.168.77.54\nsubnetMask: 255.255.255.0\ngatewayIP: 192.168.77.1\ndnsServerIP: 192.168.77.1\nconnecting...\nconnected\nHTTP/1.1 302 Found\nLocation: http://www.google.se/search?q=arduino&gws_rd=cr&ei=Wa5FV9ipLMq6swHt9Lm4Cg\nCache-Control: private\nContent-Type: text/html; charset=UTF-8\nP3P: CP=\"This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info.\"\nDate: Wed, 25 May 2016 13:53:29 GMT\nServer: gws\nContent-Length: 278\nX-XSS-Protection: 1; mode=block\nX-Frame-Options: SAMEORIGIN\nSet-Cookie: NID=79=H2CvpT9Y55kdPccpqfrPq5R6I3JyFXopiHP1jskstWS8mG8tOed0hHypMhuV2ww_--OdmSRGgREoNuozifunA9cPx07jL-H45UplTXJbaQFSVsbDSG59qb_3kQb6ePAy; expires=Thu, 24-Nov-2016 13:53:29 GMT; path=/; domain=.google.com; HttpOnly\nConnection: close\n\n<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n<TITLE>302 Moved</TITLE></HEAD><BODY>\n<H1>302 Moved</H1>\nThe document has moved\n<A HREF=\"http://www.google.se/search?q=arduino&amp;gws_rd=cr&amp;ei=Wa5FV9ipLMq6swHt9Lm4Cg\">here</A>.\n</BODY></HTML>\n\ndisconnecting.\n\n\n*******************\n```\n\n```\n********************serial print when not functioning\n\nlocalIP: 192.168.77.54\nsubnetMask: 255.255.255.0\ngatewayIP: 192.168.77.1\ndnsServerIP: 192.168.77.1\nconnecting...\nconnection failed\n\ndisconnecting.\n```\n"},"comment":{"url":"https://api.github.com/repos/ntruchsess/arduino_uip/issues/comments/259097126","html_url":"https://github.com/ntruchsess/arduino_uip/issues/156#issuecomment-259097126","issue_url":"https://api.github.com/repos/ntruchsess/arduino_uip/issues/156","id":259097126,"user":{"login":"markfoodyburton","id":11980189,"avatar_url":"https://avatars.githubusercontent.com/u/11980189?v=3","gravatar_id":"","url":"https://api.github.com/users/markfoodyburton","html_url":"https://github.com/markfoodyburton","followers_url":"https://api.github.com/users/markfoodyburton/followers","following_url":"https://api.github.com/users/markfoodyburton/following{/other_user}","gists_url":"https://api.github.com/users/markfoodyburton/gists{/gist_id}","starred_url":"https://api.github.com/users/markfoodyburton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markfoodyburton/subscriptions","organizations_url":"https://api.github.com/users/markfoodyburton/orgs","repos_url":"https://api.github.com/users/markfoodyburton/repos","events_url":"https://api.github.com/users/markfoodyburton/events{/privacy}","received_events_url":"https://api.github.com/users/markfoodyburton/received_events","type":"User","site_admin":false},"created_at":"2016-11-08T10:11:24Z","updated_at":"2016-11-08T10:11:24Z","body":"I have exactly this issue.\r\nOnce it works - it works for a long time (several hundred requests), when it fails, it keeps failing.\r\nIn my case, when it fails, I reset the device, and the arduino, and try again. \r\nI am using DHCP, which works reliably for me - every time I get a valid IP address, however it fails to connect to the remote server.\r\n\r\nAny ideas appreciated !\r\n"}}
{"actor":{"display_login":"markfoodyburton"}}