Unable to parse MarketFeeder from Websocket Message [JAVA]

Hi,

Language: Java
I’ve connected the websocket /feed/market-data-feed.
The live feed message from websocket is of type ByteBuffer.
I couldn’t parse the bytebuffer to String in java.

Even I referred your github project and this package is missing.
io.swagger.client.api.MarketFeeder.FeedResponse;

I tried using charset conversion and it’s not completely decoding.

Please provide a solution to convert bytebuffer to string.

Thanks,
Shanmuga.

@ShanmugaNarayanan

Thank you for reaching out to us. It’s great to see your interest in exploring our APIs.

It seems that your code might be missing the protobuf decoding part. We’ve provided a complete implementation in the code example linked below. Please review it, and feel free to contact us if you have any questions.

Upstox Java Websocket Market Data Example

Thank you!

Hello @shanmu

Yes, I’m facing problem in protobuf decoding part.
The java class FeedResponse.java is missing in your reference project.
Package io.swagger.client.api.MarketFeeder.FeedResponse.
If possible, please share the link to FeedResponse java class file.

Could you please review your reference project in Github related to this problem ?

Thanks,
Shanmuga

@ShanmugaNarayanan

Just to clarify, the FeedResponse is a subclass found within the MarketFeeder class. For further details, I suggest looking into the MarketFeeder class file.

Additionally, for more comprehensive insights, especially regarding the protobuf aspect, please visit the following link: Protocol Buffers (Protobuf) Classes Generation.

Thank you!

1 Like

That helps !!!
Thanks a lot @shanmu

1 Like

I am facing this problem rn,
I have generated a Upstox.java file using protoc.

but i am getting this error at:
Upstox.FeedResponse feedResponse = Upstox.FeedResponse.parseFrom(bytes.array());

Caused by: com.google.protobuf.InvalidProtocolBufferException: While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.

The example has v1 in proto file link https://assets.upstox.com/feed/market-data-feed/v1/MarketDataFeed.proto. Could this be the problem? since everyother place in the code v2 is used.