/v1/gtfs/vehiclepos/ferries sometimes gives an error


#1

When I am using /v1/gtfs/vehiclepos/ferries I sometimes get the following.

/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/protobufjs/ProtoBuf.js:1987
                            throw(e);
                            ^

Error: Illegal wire type of unknown field 0 in Message .transit_realtime.Position#decode: 7
    at ProtoBuf.Reflect.Message.decode (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/protobufjs/ProtoBuf.js:2132:39)
    at ProtoBuf.Reflect.Field.decode (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/protobufjs/ProtoBuf.js:2594:46)
    at ProtoBuf.Reflect.Message.decode (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/protobufjs/ProtoBuf.js:2139:51)
    at ProtoBuf.Reflect.Field.decode (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/protobufjs/ProtoBuf.js:2594:46)
    at ProtoBuf.Reflect.Message.decode (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/protobufjs/ProtoBuf.js:2139:51)
    at ProtoBuf.Reflect.Field.decode (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/protobufjs/ProtoBuf.js:2594:46)
    at ProtoBuf.Reflect.Message.decode (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/protobufjs/ProtoBuf.js:2137:51)
    at Function.Message.decode (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/protobufjs/ProtoBuf.js:1982:41)
    at Request._callback (/Users/nirving/projects/API/tfnsw/vehicleLocations/oauth.js:44:57)
    at Request.self.callback (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/request/request.js:200:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/request/request.js:1067:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/Users/nirving/projects/API/tfnsw/vehicleLocations/node_modules/request/request.js:988:12)

I cannot upload the code, but it does work as I have managed to produce some data as seen here https://www.google.com/maps/d/edit?mid=ziErKwtXocbE.kS_7qarRzKvg&usp=sharing


#2

Hi Nirving,

We will check and get back to you on this.


#3

Nirving - unfortunately we cannot work out where this error is occurring. Other developers have reported no issues when accessing. We’ll keep monitoring it in any case.

If any other developers can help please do jump in and respond.

Perhaps this may assist: https://github.com/dcodeIO/protobuf.js/issues ?


#4

Thanks Yvonne
I have no trouble accessing the data, i get a response back every time.
However it is decoding the response that is a problem.
I have uploaded my script and examples of failure and working content to https://drive.google.com/a/darkedges.com/folderview?id=0B9D-FwzEA1yYNVYtSThJdEZXNnc&usp=sharing

You can view a success using
node readFile.js myBinaryFile.works

You can view a failure using
node readFile.js myBinaryFile.fails

To run my script edit ferries.js and replace with you details in client_id and client_secret and run with
node ferries.js

I have tried both at home and work to eliminate any network issues i.e proxy rewriting data etc and get the same issues.

If you look at the differences between myBinaryFile.works and myBinaryFile.fails you can see there is extra data being added to the myBinaryFile.fails and I am not sure why. Unless of course the library I am using and the GTFS stream are incompatible. I am using the recommended library from Google for Node/Javascript.

Edit:
This is the exception I get from the Google Java Client

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:70)
	at com.google.protobuf.CodedInputStream.refillBuffer(CodedInputStream.java:1082)
	at com.google.protobuf.CodedInputStream.readRawByte(CodedInputStream.java:1149)
	at com.google.protobuf.CodedInputStream.readRawVarint64SlowPath(CodedInputStream.java:778)
	at com.google.protobuf.CodedInputStream.readRawVarint64(CodedInputStream.java:770)
	at com.google.protobuf.CodedInputStream.readUInt64(CodedInputStream.java:338)
	at com.google.transit.realtime.GtfsRealtime$FeedHeader.<init>(GtfsRealtime.java:1278)
	at com.google.transit.realtime.GtfsRealtime$FeedHeader.<init>(GtfsRealtime.java:1212)
	at com.google.transit.realtime.GtfsRealtime$FeedHeader$1.parsePartialFrom(GtfsRealtime.java:1311)
	at com.google.transit.realtime.GtfsRealtime$FeedHeader$1.parsePartialFrom(GtfsRealtime.java:1306)
	at com.google.protobuf.CodedInputStream.readMessage(CodedInputStream.java:495)
	at com.google.transit.realtime.GtfsRealtime$FeedMessage.<init>(GtfsRealtime.java:172)
	at com.google.transit.realtime.GtfsRealtime$FeedMessage.<init>(GtfsRealtime.java:119)
	at com.google.transit.realtime.GtfsRealtime$FeedMessage$1.parsePartialFrom(GtfsRealtime.java:221)
	at com.google.transit.realtime.GtfsRealtime$FeedMessage$1.parsePartialFrom(GtfsRealtime.java:216)
	at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:192)
	at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:209)
	at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:215)
	at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
	at com.google.transit.realtime.GtfsRealtime$FeedMessage.parseFrom(GtfsRealtime.java:418)
	at tfnsw.GetFerries.main(GetFerries.java:27)

Edit:
Exception from Ruby Client

/Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/decoder.rb:24:in `decode_each_field': 7 (Protobuf::InvalidWireType)
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:41:in `decode_from'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:35:in `decode'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:11:in `decode'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/field/message_field.rb:16:in `decode'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/field/base_field.rb:125:in `set'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:80:in `set_field_bytes'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:42:in `block in decode_from'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/decoder.rb:27:in `decode_each_field'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:41:in `decode_from'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:35:in `decode'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:11:in `decode'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/field/message_field.rb:16:in `decode'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/field/base_field.rb:125:in `set'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:80:in `set_field_bytes'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:42:in `block in decode_from'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/decoder.rb:27:in `decode_each_field'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:41:in `decode_from'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:35:in `decode'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:11:in `decode'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/field/message_field.rb:16:in `decode'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/field/base_field.rb:126:in `set'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:80:in `set_field_bytes'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:42:in `block in decode_from'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/decoder.rb:27:in `decode_each_field'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:41:in `decode_from'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:35:in `decode'
	from /Users/nirving/.rvm/gems/ruby-2.1.9/gems/protobuf-3.6.7/lib/protobuf/message/serialization.rb:11:in `decode'
	from ./gtfs.rb:14:in `<main>'

Edit:
Exception from Python Client

Traceback (most recent call last):
  File "./gtfs.py", line 8, in <module>
    feed.ParseFromString(result.read())
  File "/Library/Python/2.7/site-packages/google/protobuf/message.py", line 186, in ParseFromString
    self.MergeFromString(serialized)
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/python_message.py", line 841, in MergeFromString
    if self._InternalParse(serialized, 0, length) != length:
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/python_message.py", line 874, in InternalParse
    pos = field_decoder(buffer, new_pos, end, self, field_dict)
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/decoder.py", line 633, in DecodeRepeatedField
    if value.add()._InternalParse(buffer, pos, new_pos) != new_pos:
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/python_message.py", line 874, in InternalParse
    pos = field_decoder(buffer, new_pos, end, self, field_dict)
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/decoder.py", line 654, in DecodeField
    if value._InternalParse(buffer, pos, new_pos) != new_pos:
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/python_message.py", line 874, in InternalParse
    pos = field_decoder(buffer, new_pos, end, self, field_dict)
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/decoder.py", line 654, in DecodeField
    if value._InternalParse(buffer, pos, new_pos) != new_pos:
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/python_message.py", line 866, in InternalParse
    new_pos = local_SkipField(buffer, new_pos, end, tag_bytes)
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/decoder.py", line 827, in SkipField
    return WIRETYPE_TO_SKIPPER[wire_type](buffer, pos, end)
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/decoder.py", line 797, in _RaiseInvalidWireType
    raise _DecodeError('Tag had invalid wire type.')
google.protobuf.message.DecodeError: Tag had invalid wire type.

#5

This issue has resolved itself with no code changes on my side.


#6

This was resolved as part of other changes we made on the system