Skalar / google_distance_matrix

Ruby client for The Google Distance Matrix API.
MIT License
58 stars 45 forks source link

EOFError (end of file reached) #14

Closed joeblack81 closed 8 years ago

joeblack81 commented 8 years ago

Hi, I am using rails 3.2.13 rvm 1.9.3 when I try to test the gem from the console , every thing is going fine as this

Loading development environment (Rails 3.2.13) [1] pry(main)> matrix = GoogleDistanceMatrix::Matrix.new => #<GoogleDistanceMatrix::Matrix origins: [], destinations: []> [3] pry(main)> dest = GoogleDistanceMatrix::Place.new lng: -78.46844, lat: 38.024637 => #<GoogleDistanceMatrix::Place lat: 38.024637, lng: -78.46844> [4] pry(main)> matrix.origins << origin => [#<GoogleDistanceMatrix::Place lat: 38.055403, lng: -78.49585>] [5] pry(main)> matrix.origins << origin => [#<GoogleDistanceMatrix::Place lat: 38.055403, lng: -78.49585>] [6] pry(main)> matrix.destinations << dest => [#<GoogleDistanceMatrix::Place lat: 38.024637, lng: -78.46844>] [7] pry(main)> matrix.data [google_distance_matrix] client (elements: 1) GET http://maps.googleapis.com/maps/api/distancematrix/json?sensor=false&origins=38.0554%2C-78.49585&destinations=38.02464%2C-78.46844 => [[#<GoogleDistanceMatrix::Route origin: #<GoogleDistanceMatrix::Place lat: 38.055403, lng: -78.49585>, destination: #<GoogleDistanceMatrix::Place lat: 38.024637, lng: -78.46844>, status: "ok", distance_text: "6.0 km", distance_in_meters: 6014, duration_text: "9 mins", duration_in_seconds: 524>]]

But when I try to run the same from my code :

private def ETA(rest_lng,rest_lat,dest)

    matrix = GoogleDistanceMatrix::Matrix.new
    matrix.configure do |config|
      config.mode = 'driving'
      config.protocol = 'https'
      config.google_api_key = "xxx"
    end

    lat_lng = GoogleDistanceMatrix::Place.new lng: rest_lng, lat: rest_lat
    dest_address = GoogleDistanceMatrix::Place.new address: dest

    matrix.origins << lat_lng 
    matrix.destinations << dest_address 
    matrix.data[0][0].duration_text

end

I get this error:

[google_distance_matrix] client (elements: 1) GET https://maps.googleapis.com/maps/api/distancematrix/json?sensor=false&key=AIzaSyD0LOpPgkbygE6uCDLp0Zo_DYlxoPp4ZB4&origins=29.3394%2C47.94075&destinations=1%2Cdoha+street%2CDasma+Kuwait 2016-02-26T10:32:11.636653+00:00 app[web.1]: EOFError (end of file reached):

I am using the config : config.protocol = 'https' cause when I don't use it I get this error

2016-02-26T10:43:00.408774+00:00 app[web.1]: [google_distance_matrix] client (elements: 1) GET http://maps.googleapis.com/maps/api/distancematrix/json?sensor=false&key=AIzaSyD0LOpPgkbygE6uCDLp0Zo_DYlxoPp4ZB4&origins=29.3394%2C47.94075&destinations=1%2Cdoha+street%2CDasma+Kuwait 2016-02-26T10:43:00.418336+00:00 app[web.1]: 2016-02-26T10:43:00.418340+00:00 app[web.1]: GoogleDistanceMatrix::ClientError (GoogleDistanceMatrix::ClientError - #Net::HTTPOK:0x000000070ef9c8. REQUEST_DENIED.):

all this happen at Heroku,

but at my localhost under the same code and env I get this error:

[google_distance_matrix] client (elements: 1) GET https://maps.googleapis.com/maps/api/distancematrix/json?sensor=false&key=AIzaSyD0LOpPgkbygE6uCDLp0Zo_DYlxoPp4ZB4&origins=12%2C12&destinations=kuwait+city Completed 500 Internal Server Error in 3660ms

Errno::ECONNRESET (Connection reset by peer): app/controllers/response_controller.rb:130:in ETA' app/controllers/response_controller.rb:90:inreceiptMigs'

By the way I am not using any Proxy

Please advice , Thanks a lot

thhermansen commented 8 years ago

Hi,

Sorry for not responding earlier, I didn't notice this issue until now.

I have not seen this error before. Maybe it was a temporary issue with the API response? We are using google matrix gem in production at Skalar on Heroku and we have not seen this issue.

I'm closing this issue for now as I don't think it is directly related to some issue within the gem.