Skip to content

Commit 8db9fce

Browse files
committed
it was node.js issue - now working from AWS Lambda
1 parent ed9c832 commit 8db9fce

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

index.coffee

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ exports.handler = (event, context) ->
66
console.log "event =\n", event
77

88
client = mqtt.connect("mqtt://test.mosquitto.org:1883")
9-
#console.log "after mqtt.connect(), client = ", client
109
console.log "after mqtt.connect()"
1110

1211
for i in [1..1000]
@@ -18,6 +17,7 @@ exports.handler = (event, context) ->
1817
client.end()
1918
console.log "after cleint.end()"
2019

21-
context.done null, "SUCCESS"
22-
#setTimeout (-> context.done null, "SUCCESS"), 2000
20+
client.on "close", (-> context.done null, "SUCCESS")
21+
client.on "error", (-> context.done null, "SUCCESS")
22+
2323
return

index.js

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index_test.coffee

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ context = {
55
console.log "DONE: ", result
66
#NOTE: with process.exit 0 - even locally it doesn't work - probably the same thing happens on Lambda
77
# when commented out - it works locally
8-
#process.exit 0
9-
#throw new Error("Exit lambda")
10-
#setTimeout (-> process.exit 0), 1000
11-
#process.nextTick (-> process.exit 0)
8+
process.exit 0
129
return
1310
}
1411

index_test.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)