mapbox-java icon indicating copy to clipboard operation
mapbox-java copied to clipboard

RetryAndFollowUpInterceptor - java.io.IOException: Canceled

Open nicolasjafelle opened this issue 1 year ago • 1 comments

Issue

Multiple RetryAndFollowUpInterceptor - java.io.IOException: Canceled

Description

We are getting randomly multiple java.io.IOException: Canceled when using the Mapbox Directions SDK. Code snippet is:

SDK used

//Mapbox Directions API
implementation "com.mapbox.mapboxsdk:mapbox-sdk-services:6.13.0"

Code Snippet

for origin = "Point{type=Point, bbox=null, coordinates=[-58.449951171875, -34.55467987060547]}"
for destination = Point{type=Point, bbox=null, coordinates=[-58.484619140625, -34.57625961303711]}

private fun buildDirectionsApiClient(origin: Point, destination: Point): MapboxDirections {
    val routeOptions = RouteOptions.builder()
        .geometries(DirectionsCriteria.GEOMETRY_POLYLINE6)
        .overview(DirectionsCriteria.OVERVIEW_SIMPLIFIED)
        .profile(DirectionsCriteria.PROFILE_DRIVING)
        .coordinatesList(listOf(origin, destination))
        .build()

    return MapboxDirections.builder()
        .accessToken(accessToken)
        .routeOptions(routeOptions)
        .build()
}

and the way we are executing the calls is:

client?.enqueueCall(object : Callback<DirectionsResponse> {
            override fun onResponse(
                call: Call<DirectionsResponse>,
                response: Response<DirectionsResponse>
            ) {
                response.body()?.routes()?.firstOrNull()?.let { route ->

                    mapbox.getStyle {
                        val source: GeoJsonSource? = it.getSourceAs(ROUTE_SOURCE_ID)
                        val lineString = LineString.fromPolyline(
                            route.geometry()!!,
                            Constants.PRECISION_6
                        )
                        // Set the map's camera position taking into account the route drawing
                        val coordinateList = lineString.coordinates()
                        animateMarker.setBoundary(coordinateList)

                        val camera = mapbox.cameraForCoordinates(coordinateList, getPadding())
                        mapbox.easeTo(camera, source, lineString)
                    }
                }
            }

            override fun onFailure(call: Call<DirectionsResponse>, t: Throwable) {
                DevMetrics.monitor(errorParams("Mapbox cannot draw route points reason is ${t.cause} - ${t.message}"))
                onError()
            }
        })

Not sure if we are doing something wrong because it mostly works and draw the route but randomly it shows us this exception coming from Retrofit and OkHttp

nicolasjafelle avatar Oct 12 '23 21:10 nicolasjafelle