{"action":"created","issue":{"url":"https://api.github.com/repos/hirotakaster/TlsTcpClient/issues/1","repository_url":"https://api.github.com/repos/hirotakaster/TlsTcpClient","labels_url":"https://api.github.com/repos/hirotakaster/TlsTcpClient/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/hirotakaster/TlsTcpClient/issues/1/comments","events_url":"https://api.github.com/repos/hirotakaster/TlsTcpClient/issues/1/events","html_url":"https://github.com/hirotakaster/TlsTcpClient/issues/1","id":223619772,"number":1,"title":"Firebase cloud notification no answer","user":{"login":"maxdd","id":6155973,"avatar_url":"https://avatars1.githubusercontent.com/u/6155973?v=3","gravatar_id":"","url":"https://api.github.com/users/maxdd","html_url":"https://github.com/maxdd","followers_url":"https://api.github.com/users/maxdd/followers","following_url":"https://api.github.com/users/maxdd/following{/other_user}","gists_url":"https://api.github.com/users/maxdd/gists{/gist_id}","starred_url":"https://api.github.com/users/maxdd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxdd/subscriptions","organizations_url":"https://api.github.com/users/maxdd/orgs","repos_url":"https://api.github.com/users/maxdd/repos","events_url":"https://api.github.com/users/maxdd/events{/privacy}","received_events_url":"https://api.github.com/users/maxdd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-04-23T07:58:48Z","updated_at":"2017-04-23T17:23:59Z","closed_at":null,"body":"Hello hiro,\r\ni'm working on firebase cloud notifications with your TLS library...\r\nBelow my code snippet\r\n\r\n```\r\n// This #include statement was automatically added by the Particle IDE.\r\n#include <TlsTcpClient.h>\r\n\r\nTlsTcpClient secureClient;\r\n\r\nString TOKEN = \"*****\";\r\nString SERVER_AUTH = \"*****\";\r\n\r\nboolean sent = false;\r\n\r\nvoid setup() {\r\n    Serial.begin(9600);\r\n    delay(1000);\r\n    Serial.println(\"OK\");\r\n}\r\n\r\nvoid loop() {\r\n\r\n    if (!sent) {\r\n        sendNotificationToDevice();\r\n        Serial.println(\"Sent\");\r\n        sent = true;\r\n    }\r\n\r\n}\r\n\r\nvoid sendNotificationToDevice() {\r\n\r\n    unsigned char buff[1024];\r\n    String data = \"{\";\r\n    data += \"\\\"to\\\":\\\"\";\r\n    data += TOKEN;\r\n    data += \"\\\",\";\r\n    data += \"\\\"notification\\\":{\";\r\n    data += \"\\\"body\\\":\\\"asdsadsa\\\",\";\r\n    data += \"\\\"title\\\":\\\"Alarm\\\",\";\r\n    data += \"\\\"sound\\\":\\\"Default\\\"\";\r\n    data += \"}}\";\r\n\r\n    if (secureClient.connect(\"fcm.googleapis.com\", 443)){\r\n        int len = sprintf((char *)buff, \"POST /fcm/send HTTP/1.1\\r\\nHost: fcm.googleapis.com\\r\\nAuthorization: key=%s\\r\\nContent-Type: application/json\\r\\nContent-Length: %d\\r\\n\\r\\n%s\", SERVER_AUTH.c_str(), data.length(), data.c_str());\r\n        Serial.println(String(len));\r\n        secureClient.write(buff, len);\r\n        Serial.println((char*)buff);\r\n    }\r\n\r\n    delay(2000);\r\n\r\n    while(1) {\r\n       // read renponse.\r\n       memset(buff, 0, sizeof(buff));\r\n       int ret = secureClient.read(buff, sizeof(buff) - 1);\r\n       if (ret == MBEDTLS_ERR_SSL_WANT_READ) {\r\n           delay(100);\r\n           continue;\r\n       } else if (ret <= 0) {\r\n           // no more read.\r\n           Serial.println(\"\\nNo answer\");\r\n           break;\r\n       } else if (ret > 0){\r\n           Serial.println((char *)buff);\r\n       }\r\n}\r\n\r\n    /*while (secureClient.available()) {\r\n        char c = secureClient.read();\r\n        Serial.print(c);\r\n    }*/\r\n\r\n    Serial.println(\"\\nFinished!\");\r\n    //secureClient.stop();\r\n}\r\n```\r\n\r\nThe serial is showing a well formatted http request but when the client wait for read it reports No Answer\r\n\r\nI noticed also\r\n`int r = secureClient.connect(\"fcm.googleapis.com\", 443);`\r\nit returns -28928\r\nwhile\r\n`int r1 = secureClient.write(buff, len);`\r\nit returns -1\r\n\r\nHow can i fix this?"},"comment":{"url":"https://api.github.com/repos/hirotakaster/TlsTcpClient/issues/comments/296460632","html_url":"https://github.com/hirotakaster/TlsTcpClient/issues/1#issuecomment-296460632","issue_url":"https://api.github.com/repos/hirotakaster/TlsTcpClient/issues/1","id":296460632,"user":{"login":"hirotakaster","id":203933,"avatar_url":"https://avatars3.githubusercontent.com/u/203933?v=3","gravatar_id":"","url":"https://api.github.com/users/hirotakaster","html_url":"https://github.com/hirotakaster","followers_url":"https://api.github.com/users/hirotakaster/followers","following_url":"https://api.github.com/users/hirotakaster/following{/other_user}","gists_url":"https://api.github.com/users/hirotakaster/gists{/gist_id}","starred_url":"https://api.github.com/users/hirotakaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hirotakaster/subscriptions","organizations_url":"https://api.github.com/users/hirotakaster/orgs","repos_url":"https://api.github.com/users/hirotakaster/repos","events_url":"https://api.github.com/users/hirotakaster/events{/privacy}","received_events_url":"https://api.github.com/users/hirotakaster/received_events","type":"User","site_admin":false},"created_at":"2017-04-23T17:23:59Z","updated_at":"2017-04-23T17:23:59Z","body":"Hi, @maxdd \r\nThis library is not the same with ESP8266, `TlsTcpClient::init` MUST be needed.\r\nSSL config&initialized.. and some other important method running in this method."}}
{"actor":{"display_login":"hirotakaster"}}