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

Error 'java.io.EOFException' when transferred Android application from WAMP to external server. #2199

Closed
ghost opened this issue Feb 14, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 14, 2017

Hello,

I have a problem with retrieving data from my server using retrofit2.
While I was running my Android application on local server, data was retrieving properly.
I changed the server to external one, and then the problem occured.

My logCat:

               java.io.EOFException: End of input at line 1 column 1
                   at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1407)
                   at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:553)
                   at com.google.gson.stream.JsonReader.peek(JsonReader.java:429)
                   at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:201)
                   at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37)
                   at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25)
                   at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:116)
                   at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
                   at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:106)
                   at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
                   at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                   at java.lang.Thread.run(Thread.java:818)

Retrofit class:

    public void init() {
        OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder();

        HttpLoggingInterceptor debugger =
                new HttpLoggingInterceptor()
                        .setLevel(HttpLoggingInterceptor.Level.BODY);
        okHttpClient
                .addInterceptor(debugger);

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(Constants.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .client(okHttpClient.build())
                .build();

        RequestInterface requestInterface = retrofit.create(RequestInterface.class);

        String email = pref.getString(Constants.EMAIL, "");
        System.out.println(email);
        String id_group = pref.getString(Constants.ID_GROUP, "");
        System.out.println(id_group);
        String nazwa = pref.getString(Constants.NAZWA, "");

        Integer id_int_group = Integer.parseInt(id_group);
        Bookmark bookmark = new Bookmark(email, id_int_group, nazwa);

        ServerRequest request2 = new ServerRequest();
        request2.setOperation(Constants.GET_MY_GROUPS);
        request2.setBookmark(bookmark);

        Call<List<Bookmark>> response2 = requestInterface.operation2(request2);

        response2.enqueue(new Callback<List<Bookmark>>() {

            @Override
            public void onResponse(Call<List<Bookmark>> call, retrofit2.Response<List<Bookmark>> response) {

                listOfBookmarks = response.body();
                bookmarkToString();
                simpleAdapter.notifyDataSetChanged(); // refresh listivew
            }

            @Override
            public void onFailure(Call<List<Bookmark>> call, Throwable t) {

                Log.d(Constants.TAG, "Nie zaladowano!", t);

            }
        });
    }

RequestInterface class:

    @POST("/")
    Call<List<Bookmark>> operation2(@Body ServerRequest request2);

Any solutions appreciated. Thanks!

@JakeWharton
Copy link
Member

An EOFException comes from the socket and indicates that the connection was terminated before all the data was available. Perhaps your server is timing out. This is not a problem with Retrofit, though.

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

No branches or pull requests

1 participant