Closed MedericPixium closed 4 years ago
We have also done the following test:
Functions:
This works with no issue.
Functions:
The JavaScript reads empty objects per the referred issue above.
This helped us pinpoint the issue is coming from the JavaScript reading. However we have still not managed to make the reading work.
readMessages()
returns an array of Message
object. The actual payload can be printed with messages[i].payload
.
Refer to https://aws.github.io/aws-greengrass-core-sdk-js/aws-greengrass-core-sdk.StreamManager.StreamManagerClient.html and https://aws.github.io/aws-greengrass-core-sdk-js/aws-greengrass-core-sdk.StreamManager.Message.html
readMessages()
returns an array ofMessage
object. The actual payload can be printed withmessages[i].payload
.Refer to https://aws.github.io/aws-greengrass-core-sdk-js/aws-greengrass-core-sdk.StreamManager.StreamManagerClient.html and https://aws.github.io/aws-greengrass-core-sdk-js/aws-greengrass-core-sdk.StreamManager.Message.html
Thank you. Compare to python for some reason we are unable to log the whole Message
object and this got us off track.
Furthermore @massi-ang would you have any insight on the other issue with the unhandled promise return
You can add a unhandledRejection
callback. See https://nodejs.org/api/process.html#process_event_unhandledrejection
We managed to make everything work! thanks a lot!
Hi @MedericPixium, Could you please share some details regarding your solution of the connection refused error? I'm currently struggling with the same for several hours. I'm using Python, but tried with NodeJS as well - got same error message as you. Apparently in both cases it ends up with connection failure.
To be more specific, I'm sharing logs:
[2020-10-09T11:18:50.892Z][ERROR]-streammanagerclient.py:134,Connection error while connecting to server: [Errno 111] Connect call failed ('127.0.0.1', 8088)
[2020-10-09T11:18:50.892Z][FATAL]-lambda_runtime.py:142,Failed to import handler function "index.lambda_handler" due to exception: [Errno 111] Connect call failed ('127.0.0.1', 8088)
My situation is almost identical. I found my SM Client probably can't access SM service running on a local host.
However, port 8088 on localhost is opened, SM authentication is disabled, tried to run lambda with and without GG container - no results.
What's worth mentioning is that SM service gets initialized correctly - confirmed by logs, I'm also able to connect via nc -v 127.0.0.1 8088
.
Of course, all the prerequisites and requirements for SM are met. Thanks in advance!
EDIT: Just tried to move lambda function with all it's dependencies to the temp dir under root and execute .py file manually. It results with "Broken bit parity" error at 'create_message_stream" line. Looks like this way I can establish connection with 127.0.0.1:8088, but facing some other issue. At same time, lambda deployed via GG still complains about connection failure.
@kaku0 can you verify if you are using the latest SDK and the latest version of Greengrass?
@massi-ang Sure!
Those were versions I've used: GGC Version: v1.11 GG Python SDK Version: v1.5
According to compability section, it should be all fine. But just in case, I just updated Python SDK to v1.6. Unfortunately, still the same. Logs seem to be a little different, but final effect is the same:
[2020-10-09T15:14:52.91Z][ERROR]-streammanagerclient.py:188,Unable to read from socket, likely socket is closed or server died
[2020-10-09T15:14:52.91Z][ERROR]-streammanagerclient.py:145,Connection error while connecting to server: [Errno 111] Connect call failed ('127.0.0.1', 8088)
[2020-10-09T15:15:05.354Z][ERROR]-streammanagerclient.py:188,Unable to read from socket, likely socket is closed or server died
[2020-10-09T15:15:05.354Z][ERROR]-streammanagerclient.py:145,Connection error while connecting to server: [Errno 111] Connect call failed ('127.0.0.1', 8088)
Also, I tried again to move all the lambda files to the root and run .py manually as a root. Still the same - "Broken bit parity". Found something related to this in GGStreamManager.log file:
[2020-10-09T15:16:33.89Z][ERROR]- (nioEventLoopGroup-3-1) com.amazonaws.iot.greengrass.streammanager.server.handlers.CreateMessageStreamRequestHandler: Encountered unknown exception while creating message stream python_stream_manager_test
[2020-10-09T15:16:33.89Z][ERROR]-org.mapdb.DBException$PointerChecksumBroken: Broken bit parity
[2020-10-09T15:16:33.89Z][ERROR]- at org.mapdb.DataIO.parity4Get(DataIO.java:476) ~[AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at org.mapdb.StoreWAL.longStackLoadChunk(StoreWAL.kt:732) ~[AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at org.mapdb.StoreWAL.longStackTake(StoreWAL.kt:831) ~[AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at org.mapdb.StoreDirectAbstract.allocateRecid(StoreDirectAbstract.kt:255) ~[AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at org.mapdb.StoreWAL.put(StoreWAL.kt:383) ~[AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at org.mapdb.HTreeMap.valueWrap(HTreeMap.kt:1208) ~[AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at org.mapdb.HTreeMap.putprotected(HTreeMap.kt:344) ~[AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at org.mapdb.HTreeMap.put(HTreeMap.kt:324) ~[AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at com.amazonaws.iot.greengrass.streammanager.dao.MapDbMetadataDao.put(MapDbMetadataDao.java:73) ~[AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at com.amazonaws.iot.greengrass.streammanager.store.log.LogStore.createMessageStream(LogStore.java:113) ~[AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at com.amazonaws.iot.greengrass.streammanager.server.handlers.CreateMessageStreamRequestHandler.handle(CreateMessageStreamRequestHandler.java:41) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at com.amazonaws.iot.greengrass.streammanager.server.handlers.MessageStreamHandler.channelRead(MessageStreamHandler.java:130) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:321) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:295) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:321) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:295) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [AWSGreengrassStreamManager.jar:?]
[2020-10-09T15:16:33.89Z][ERROR]- at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]
[2020-10-09T15:16:33.892Z][DEBUG]- (nioEventLoopGroup-3-1) com.amazonaws.iot.greengrass.streammanager.server.protocol.ResponseHelper: Respond request f95fa1f3-712e-4fc4-b419-98fadc14a1d9 with status UnknownFailure
We have been deploying lambda functions in Javascript (Node.js 12.x) Writing gives us no issue as we get the OK result when appending to the stream.
However when trying to read from the stream (with js code below) we get only empty messages. We have tried the python SDK and there is no issue. However we would like to use the Javascript as the rest of our functions are using Javascript as well.
Extract from Read function log:
Another issue we get (not sure if it's linked) is:
This happens with every function that tries to read or write to the stream before it has finished initialization.
GreenGrass Version: 1.10.2 GreenGrass JS SDK Version: 1.6.1
This code is taken from the following tutorial:
https://docs.aws.amazon.com/greengrass/latest/developerguide/work-with-streams.html
We have also done the following test:
Functions:
This works with no issue.
Functions:
The JavaScript reads empty objects per the referred issue above.
Non Functional JS Code
Create Stream
Write to Stream
Read from Stream
Functional Python Code
Create Stream
Write to Stream
Read from Stream