question

Gamingtilidrop avatar image
Gamingtilidrop asked

Issue of Register ID

HI^^ Q1. I don’t know how to receive ‘Register Id’ by app to send the message. SO, I coded like this, if (action.equals("sendMessage")) { // String message = request.getParameter("message"); String Token = "Act|.."; //this token is valid.!! String regId = "amzn1.adm-registration.v2.Y29tLmFtYXpvbi5EZXZpY2VNZXNzYWdpbmcuUmVnaXN0cmF0aW9uSWRFbmNyeXB0aW9uS2V5ITEhc0NWSFNhWWpVMmxOL1dqd3I2UG9ralRWWXNDT0RMampDMGpHcm13YVQvRTZlc2wvcXlJZUVUQnZIQ2dWQWZvUkp4TWZnU2ErK2NNL1RNdUtHZzNUdWtvSEtiS0tuekYrMk5NdzdXVXN3QVNGSkVQRjVDQk1SMnZGbEw4emFORUZLUlVWTzhYQ3VwSnN4VTU0UXJKaHIrMUZUSDQ2TnpGRFk4eU5RT0RyV1J4ZTNVczhKai9EMC9lSStNTzU4Q3pMeHhLZEppTlVhdGRVcUM1VjFueUpTaGtSRCtxb3lMSkVReW5DL2VQc05xSjh6MitkbWFnWkFJT1JsUmNlVE5PNGs0VUFoY2NtT0tlRkd6SFJtZlJJS1IxQzBuMkdGZmZjNW5lWEd1SHAvTDA9IUFtS3lYaEVuM3RGeGp1RllsT0MyMkE9PQ"; //String regId= request.getParameter("regId"); String resp = "Success"; try { sendMessageToDevice(regId, Token); } catch (Exception e) { e.printStackTrace(); resp = "fail"; } response.getWriter().write(resp); } ....... public void sendMessageToDevice(String registrationId, String accessToken) throws Exception { JSONObject payload = new JSONObject(); JSONObject data = new JSONObject(); data.put("firstKey", "firstValue"); data.put("secondKey", "secondValue"); ............. So, I got the "Success" message on Web. but the sample app didn't receive any message.!! why i can not receive any message?? ========================================================================================================================= Q2. I know “MyServerMsgHandler.java” sent ‘Register Id’ to app server.(String fullUrl = URL + "/ADMAdmin/register?device="+ registrationId; ) Should I give action to register using the code below? String action = request.getParameter("action"); if (action.equals("getAuthToken")) {..... ========================================================================================================================= I would like to test in local environment. INPUT: 127.0.0.1 8080 RESULT: ERROR failed to connect to /127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused) java.net.ConnectException: failed to connect to /127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused) at libcore.io.IoBridge.connect(IoBridge.java:114) ... INPUT http://localhost 8080 RESULT: ERROR failed to connect to localhost/127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused) java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused) at libcore.io.IoBridge.connect(IoBridge.java:114) ..... INPUT: http://192.1xx.x.x // I got this ip address using instruction "ipconfig" through cmd. 8080 RESULT: ERROR http://192.168.1.2:8080/ADMAdmin/register?device=amzn1.adm-registration.v2.Y29tLmFtYXpvbi5EZXZpY2VNZXNzYWdpbmcuUmVnaXN0cmF0aW9uSWRFbmNyeXB0aW9uS2V5ITEhc0NWSFNhWWpVMmxOL1dqd3I2UG9ralRWWXNDT0RMampDMGpHcm13YVQvRTZlc2wvcXlJZUVUQnZIQ2dWQWZvUkp4TWZnU2ErK2NNL1RNdUtHZzNUdWtvSEtiS0tuekYrMk5NdzdXVXN3QVNGSkVQRjVDQk1SMnZGbEw4emFORUZLUlVWTzhYQ3VwSnN4VTU0UXJKaHIrMUZUSDQ2TnpGRFk4eU5RT0RyV1J4ZTNVczhKai9EMC9lSStNTzU4Q3pMeHhLZEppTlVhdGRVcUM1VjFueUpTaGtSRCtxb3lMSkVReW5DL2VQc05xSjh6MitkbWFnWkFJT1JsUmNlVE5PNGs0VUFoY2NtT0tlRkd6SFJtZlJJS1IxQzBuMkdGZmZjNW5lWEd1SHAvTDA9IUFtS3lYaEVuM3RGeGp1RllsT0MyMkE9PQ java.io.FileNotFoundException: http://192.168.1.2:8080/ADMAdmin/register?device=amzn1.adm-registration.v2.Y29tLmFtYXpvbi5EZXZpY2VNZXNzYWdpbmcuUmVnaXN0cmF0aW9uSWRFbmNyeXB0aW9uS2V5ITEhc0NWSFNhWWpVMmxOL1dqd3I2UG9ralRWWXNDT0RMampDMGpHcm13YVQvRTZlc2wvcXlJZUVUQnZIQ2dWQWZvUkp4TWZnU2ErK2NNL1RNdUtHZzNUdWtvSEtiS0tuekYrMk5NdzdXVXN3QVNGSkVQRjVDQk1SMnZGbEw4emFORUZLUlVWTzhYQ3VwSnN4VTU0UXJKaHIrMUZUSDQ2TnpGRFk4eU5RT0RyV1J4ZTNVczhKai9EMC9lSStNTzU4Q3pMeHhLZEppTlVhdGRVcUM1VjFueUpTaGtSRCtxb3lMSkVReW5DL2VQc05xSjh6MitkbWFnWkFJT1JsUmNlVE5PNGs0VUFoY2NtT0tlRkd6SFJtZlJJS1IxQzBuMkdGZmZjNW5lWEd1SHAvTDA9IUFtS3lYaEVuM3RGeGp1RllsT0MyMkE9PQ at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:177) ...... ================================================================================================ Q3 *****( i think the input is correct, but I got an error) INPUT: 192.16x.x.x // I got this ip address using instruction "ipconfig" through cmd. 8080 RESULT: ERROR Protocol not found: 192.168.1.2:8080/ADMAdmin/register?device=amzn1.adm-registration.v2.Y29tLmFtYXpvbi5EZXZpY2VNZXNzYWdpbmcuUmVnaXN0cmF0aW9uSWRFbmNyeXB0aW9uS2V5ITEhc0NWSFNhWWpVMmxOL1dqd3I2UG9ralRWWXNDT0RMampDMGpHcm13YVQvRTZlc2wvcXlJZUVUQnZIQ2dWQWZvUkp4TWZnU2ErK2NNL1RNdUtHZzNUdWtvSEtiS0tuekYrMk5NdzdXVXN3QVNGSkVQRjVDQk1SMnZGbEw4emFORUZLUlVWTzhYQ3VwSnN4VTU0UXJKaHIrMUZUSDQ2TnpGRFk4eU5RT0RyV1J4ZTNVczhKai9EMC9lSStNTzU4Q3pMeHhLZEppTlVhdGRVcUM1VjFueUpTaGtSRCtxb3lMSkVReW5DL2VQc05xSjh6MitkbWFnWkFJT1JsUmNlVE5PNGs0VUFoY2NtT0tlRkd6SFJtZlJJS1IxQzBuMkdGZmZjNW5lWEd1SHAvTDA9IUFtS3lYaEVuM3RGeGp1RllsT0MyMkE9PQ java.net.MalformedURLException: Protocol not found: 192.168.1.2:8080/ADMAdmin/register?device=amzn1.adm-registration.v2.Y29tLmFtYXpvbi5EZXZpY2VNZXNzYWdpbmcuUmVnaXN0cmF0aW9uSWRFbmNyeXB0aW9uS2V5ITEhc0NWSFNhWWpVMmxOL1dqd3I2UG9ralRWWXNDT0RMampDMGpHcm13YVQvRTZlc2wvcXlJZUVUQnZIQ2dWQWZvUkp4TWZnU2ErK2NNL1RNdUtHZzNUdWtvSEtiS0tuekYrMk5NdzdXVXN3QVNGSkVQRjVDQk1SMnZGbEw4emFORUZLUlVWTzhYQ3VwSnN4VTU0UXJKaHIrMUZUSDQ2TnpGRFk4eU5RT0RyV1J4ZTNVczhKai9EMC9lSStNTzU4Q3pMeHhLZEppTlVhdGRVcUM1VjFueUpTaGtSRCtxb3lMSkVReW5DL2VQc05xSjh6MitkbWFnWkFJT1JsUmNlVE5PNGs0VUFoY2NtT0tlRkd6SFJtZlJJS1IxQzBuMkdGZmZjNW5lWEd1SHAvTDA9IUFtS3lYaEVuM3RGeGp1RllsT0MyMkE9PQ at java.net.URL. (URL.java:178) at java.net.URL. (URL.java:127) at com.amazon.sample.admmessenger.MyServerMsgHandler$1.doInBackground(MyServerMsgHandler.java:55) ...... So, I changed the network firewall setting(on control panel. not router). But It's not working. Is the "server_address" above correct? ========================================================================================================================= Message was edited by: Gamingtilidrop null
amazon device messaging
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gamingtilidrop avatar image
Gamingtilidrop answered
About Q3 , I tested the sample app using real kindle device. not emulator.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gamingtilidrop avatar image
Gamingtilidrop answered
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gamingtilidrop avatar image
Gamingtilidrop answered
Thanks a lot.^^! i post one more time. because there are no sign in the title like '?'. http://127.0.0.1:8080 is working. so i am sure My server is running on port 8080. I input like below, http://127.0.0.1 8080 but Result : Error failed to connect to /127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused) java.net.ConnectException: failed to connect to /127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused) at libcore.io.IoBridge.connect(IoBridge.java:114) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) ........ So, I checked off the windows Firewall in the Control Panel. But, It's still occurred above error. Q1 why this error is occurred?? ================== Anyway I sent the message to the sample app. and then I confirm. that is success. But, I saw the warning below through Logcat of eclipse. SampleADMMessageHandler:onMessage Unable to extract message data.Make sure that msgKey and timeKey values match data elements of your JSON message Q2. Why this warning is occurred?
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.