Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidProtocolBufferException breaks the loop #12

Open
answerquest opened this issue Aug 14, 2018 · 1 comment
Open

InvalidProtocolBufferException breaks the loop #12

answerquest opened this issue Aug 14, 2018 · 1 comment
Labels

Comments

@answerquest
Copy link

Every once in a while this error happens and the program stops. It may be the case that it read the feed while it was being written on server. I'm running on a test server and haven't put in mechanisms at present to handle that situation.

Instead of halting the whole program there, it would be great to handle the exception and continue to next iteration. And maybe error out only when there's been something like 10 exceptions in a row. (so, a max retries setting like we have in download managers)

2018-08-14 06:21:35,034 INFO  [VisualizerService.java:197] : vehicles updated: 340
2018-08-14 06:21:35,038 INFO  [VisualizerService.java:227] : refresh interval: 10
2018-08-14 06:21:45,039 INFO  [VisualizerService.java:134] : refreshing vehicle positions
2018-08-14 06:21:55,221 INFO  [VisualizerService.java:134] : refreshing vehicle positions
2018-08-14 06:21:55,470 ERROR [VisualizerService.java:238] : error refreshing GTFS-realtime data
com.google.protobuf.InvalidProtocolBufferException: While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either than the input has been truncated or that an embedded message misreported its own length.
	at com.google.protobuf.InvalidProtocolBufferException.truncatedMessage(InvalidProtocolBufferException.java:49)
	at com.google.protobuf.CodedInputStream.refillBuffer(CodedInputStream.java:693)
	at com.google.protobuf.CodedInputStream.readRawByte(CodedInputStream.java:734)
	at com.google.protobuf.CodedInputStream.readRawVarint32(CodedInputStream.java:338)
	at com.google.protobuf.CodedInputStream.readMessage(CodedInputStream.java:269)
	at com.google.transit.realtime.GtfsRealtime$VehiclePosition$Builder.mergeFrom(GtfsRealtime.java:5317)
	at com.google.transit.realtime.GtfsRealtime$VehiclePosition$Builder.mergeFrom(GtfsRealtime.java:5064)
	at com.google.protobuf.CodedInputStream.readMessage(CodedInputStream.java:275)
	at com.google.transit.realtime.GtfsRealtime$FeedEntity$Builder.mergeFrom(GtfsRealtime.java:1915)
	at com.google.transit.realtime.GtfsRealtime$FeedEntity$Builder.mergeFrom(GtfsRealtime.java:1675)
	at com.google.protobuf.CodedInputStream.readMessage(CodedInputStream.java:275)
	at com.google.transit.realtime.GtfsRealtime$FeedMessage$Builder.mergeFrom(GtfsRealtime.java:465)
	at com.google.transit.realtime.GtfsRealtime$FeedMessage$Builder.mergeFrom(GtfsRealtime.java:263)
	at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:300)
	at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:238)
	at com.google.protobuf.AbstractMessageLite$Builder.mergeFrom(AbstractMessageLite.java:202)
	at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:738)
	at com.google.transit.realtime.GtfsRealtime$FeedMessage.parseFrom(GtfsRealtime.java:208)
	at org.onebusaway.gtfs_realtime.visualizer.VisualizerService.refresh(VisualizerService.java:137)
	at org.onebusaway.gtfs_realtime.visualizer.VisualizerService.access$200(VisualizerService.java:52)
	at org.onebusaway.gtfs_realtime.visualizer.VisualizerService$RefreshTask.run(VisualizerService.java:236)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:844)

@barbeau barbeau added the bug label Aug 14, 2018
@answerquest
Copy link
Author

Hi folks, just wanted to let others who are facing the same bug know that I figured out a workaround : I'm terminating and re-launching the program once every hour on my server.

Here's an abridged contents of a .sh file that is run through crontab once every hour (note: you may need sudo permissions etc for the pkill command)

# kill any app currently running having "onebusaway" in the command line
pkill -f onebusaway

# Start onebusaway in background, so it keeps running even after you logout from ssh session
nohup java -jar /root/onebusaway-gtfs-realtime-visualizer/target/onebusaway-gtfs-realtime-visualizer-0.0.1-SNAPSHOT.jar --vehiclePositionsUrl=[URL] &

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants