{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/419","repository_url":"https://api.github.com/repos/Azure/azure-iot-sdks","labels_url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/419/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/419/comments","events_url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/419/events","html_url":"https://github.com/Azure/azure-iot-sdks/issues/419","id":143484107,"number":419,"title":"An unhandled exception occurred. Error: One of your scripts caused the service to become unresponsive and the service was restarted. This is commonly caused by a script executing an infinite loop or a long, blocking operation. The service was restarted after the script continuously executed for longer than 5000 milliseconds. at process.Server._registerUncaughtExceptionListenerAndCreateHttpServer._onUncaughtException (D:\\home\\site\\wwwroot\\node_modules\\azure-mobile-services\\runtime\\server.js:218:17) at process.EventEmitter.emit (events.js:126:20)","user":{"login":"artyomovs","id":4401664,"avatar_url":"https://avatars.githubusercontent.com/u/4401664?v=3","gravatar_id":"","url":"https://api.github.com/users/artyomovs","html_url":"https://github.com/artyomovs","followers_url":"https://api.github.com/users/artyomovs/followers","following_url":"https://api.github.com/users/artyomovs/following{/other_user}","gists_url":"https://api.github.com/users/artyomovs/gists{/gist_id}","starred_url":"https://api.github.com/users/artyomovs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artyomovs/subscriptions","organizations_url":"https://api.github.com/users/artyomovs/orgs","repos_url":"https://api.github.com/users/artyomovs/repos","events_url":"https://api.github.com/users/artyomovs/events{/privacy}","received_events_url":"https://api.github.com/users/artyomovs/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Azure/azure-iot-sdks/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":{"login":"pierreca","id":4979572,"avatar_url":"https://avatars.githubusercontent.com/u/4979572?v=3","gravatar_id":"","url":"https://api.github.com/users/pierreca","html_url":"https://github.com/pierreca","followers_url":"https://api.github.com/users/pierreca/followers","following_url":"https://api.github.com/users/pierreca/following{/other_user}","gists_url":"https://api.github.com/users/pierreca/gists{/gist_id}","starred_url":"https://api.github.com/users/pierreca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pierreca/subscriptions","organizations_url":"https://api.github.com/users/pierreca/orgs","repos_url":"https://api.github.com/users/pierreca/repos","events_url":"https://api.github.com/users/pierreca/events{/privacy}","received_events_url":"https://api.github.com/users/pierreca/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-03-25T11:56:28Z","updated_at":"2016-03-27T09:10:33Z","closed_at":null,"body":"Hi guys! \r\nPlease, help me with issue which I've been working with for three days. \r\nFirst I apologize for my English.\r\n\r\nI'm trying to send Cloud2Device message using node js script that is hosted on my mobile-services api.\r\n[here is sample](https://github.com/Azure/azure-iot-sdks/blob/master/node/service/samples/send_c2d_message.js)\r\n\r\nThen Azure said me that I need to install azure-iothub and azure-iot-common. \r\nI have done it with git service + IDE. \r\n\r\nNow when I run my scripts Azure show in logs:\r\n`An unhandled exception occurred. Error: One of your scripts caused the service to become unresponsive and the service was restarted. This is commonly caused by a script executing an infinite loop or a long, blocking operation. The service was restarted after the script continuously executed for longer than 5000 milliseconds. at process.Server._registerUncaughtExceptionListenerAndCreateHttpServer._onUncaughtException (D:\\home\\site\\wwwroot\\node_modules\\azure-mobile-services\\runtime\\server.js:218:17) at process.EventEmitter.emit (events.js:126:20)`. \r\nIt occurs on function:\r\n```\r\n client.open(function (err) {\r\n        if (err) {\r\n            console.error('Could not connect: ' + err.message);\r\n        } else {\r\n            console.log('Client connected');\r\n\r\n            // Отправлять сообщение\r\n            var data = JSON.stringify({ text : 'foo' });\r\n            var message = new Message(data);\r\n            console.log(\"json message is created\")\r\n            console.log('Sending message: ' + message.getData());\r\n            client.send(targetDevice, message, printResultFor('send'));\r\n            console.log(\"message has been sent\");\r\n             \r\n           }\r\n}\r\n```\r\n\r\nHere is my full script: \r\n`exports.post = function(request, response) {\r\n    // Use \"request.service\" to access features of your mobile service, e.g.:\r\n    //   var tables = request.service.tables;\r\n    //   var push = request.service.push;\r\n    \r\n        \r\n\r\n    response.send(statusCodes.OK, { message : 'Hello World!' });\r\n};\r\n\r\n\r\n//GET\r\nexports.get = function(request, response) {\r\n    \r\n    \r\n    response.send(statusCodes.OK, { message : 'Sending message to device' });\r\n    \r\n    var Client = require('azure-iothub').Client;\r\n    console.log(\"client has been created\");\r\n    \r\n    var Message = require('azure-iot-common').Message;\r\n    console.log(\"message has been created\");\r\n    \r\n    \r\n    var connectionString = \"HostName=***.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=***\";\r\n    console.log(connectionString);\r\n    var targetDevice = 'devicesergey';\r\n    \r\n    \r\n    var client = Client.fromConnectionString(connectionString);\r\n    \r\n    console.log(\"client has been created\");\r\n    \r\n    \r\n    client.open();\r\n    console.log(\"client has been opened\");\r\n    \r\n    client.open(function (err) {\r\n        if (err) {\r\n            console.error('Could not connect: ' + err.message);\r\n        } else {\r\n            console.log('Client connected');\r\n\r\n            // Отправлять сообщение\r\n            var data = JSON.stringify({ text : 'foo' });\r\n            var message = new Message(data);\r\n            console.log(\"json message is created\")\r\n            console.log('Sending message: ' + message.getData());\r\n            client.send(targetDevice, message, printResultFor('send'));\r\n            console.log(\"message has been sent\");\r\n             \r\n           }\r\n});\r\n```\r\nfunction printResultFor(op) {\r\n  return function printResult(err, res) {\r\n    if (err) {\r\n      console.log(op + ' error: ' + err.toString());\r\n    } else {\r\n      console.log(op + ' status: ' + res.constructor.name);\r\n    }\r\n  };\r\n}    \r\n};\r\n\r\n``````\r\n\r\nI don't know exactly what Im supposed to do to figure out this stuff.  \r\nI would be very greatfull if you helped me. \r\nThank you!\r\n"},"comment":{"url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/comments/202022546","html_url":"https://github.com/Azure/azure-iot-sdks/issues/419#issuecomment-202022546","issue_url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/419","id":202022546,"user":{"login":"artyomovs","id":4401664,"avatar_url":"https://avatars.githubusercontent.com/u/4401664?v=3","gravatar_id":"","url":"https://api.github.com/users/artyomovs","html_url":"https://github.com/artyomovs","followers_url":"https://api.github.com/users/artyomovs/followers","following_url":"https://api.github.com/users/artyomovs/following{/other_user}","gists_url":"https://api.github.com/users/artyomovs/gists{/gist_id}","starred_url":"https://api.github.com/users/artyomovs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artyomovs/subscriptions","organizations_url":"https://api.github.com/users/artyomovs/orgs","repos_url":"https://api.github.com/users/artyomovs/repos","events_url":"https://api.github.com/users/artyomovs/events{/privacy}","received_events_url":"https://api.github.com/users/artyomovs/received_events","type":"User","site_admin":false},"created_at":"2016-03-27T09:10:33Z","updated_at":"2016-03-27T09:10:33Z","body":"No, I haven't tried to run locally. I will do it. \r\nBut I don't know how to find out the node js version on Azure mobile services. \r\nBy the way, sometimes script just doesn't work and sometimes I get error 503 (please find the screenshot)/\r\n![screenshot_48](https://cloud.githubusercontent.com/assets/4401664/14064680/e57b9ae6-f414-11e5-8cbe-b2c9d73a9a9e.png)\r\n"}}