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

connection reset by peer #2730

Closed
onionYJK opened this issue Jul 18, 2016 · 3 comments
Closed

connection reset by peer #2730

onionYJK opened this issue Jul 18, 2016 · 3 comments
Labels
bug Bug in existing code needs info More information needed from reporter

Comments

@onionYJK
Copy link

java.net.SocketException: sendto failed: ECONNRESET (Connection reset by peer)
cause = {ErrnoException@22155} "android.system.ErrnoException: sendto failed: ECONNRESET (Connection reset by peer)"
detailMessage = "sendto failed: ECONNRESET (Connection reset by peer)"
stackState = {Object[36]@22157}
stackTrace = {StackTraceElement[0]@22158}
suppressedExceptions = {Collections$EmptyList@22159} size = 0
shadow$klass = {Class@20115} "class java.net.SocketException"
shadow$monitor = -1092557150

当我上传5张或者5张以上的图片时,就会报这个错误。
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.setType(MultipartBody.FORM)
.addFormDataPart("uid", MySharedPreferences.getUserInfo(TweetActivity.this).getUid())
.addFormDataPart("coustumeclass", selectCategory.getCname())
.addFormDataPart("clothestype", selectCategory.getClothestype())
.addFormDataPart("longitude", myLocation.getLongitude() + "")
.addFormDataPart("latitude", myLocation.getLatitude() + "")
.addFormDataPart("status", status);

    if (selectBrand != null && selectBrand.getBid() != null)
        builder.addFormDataPart("bid", selectBrand.getBid());

    if (selectStore != null && selectStore.getSaid() != null) {
        builder.addFormDataPart("signstores", selectStore.getStid());
        builder.addFormDataPart("said", selectStore.getSaid());
        builder.addFormDataPart("storesname", selectStore.getStname());
        builder.addFormDataPart("stlongitude", selectStore.getStlongitude());
        builder.addFormDataPart("stlatitude", selectStore.getStlatitude());
    }

    if (selectSize != null)
        builder.addFormDataPart("size", selectSize);

    if (!modeTexts.isEmpty()) {
        String s = "";
        for (int i = 0; i < modeTexts.size(); i++) {
            s += modeTexts.get(i) + Constant.TWEET_TEXT_DOT;
        }
        builder.addFormDataPart("introduce", s.substring(0, s.length() - Constant.TWEET_TEXT_DOT.length()));
    }

    if (selectBrand.getSaid() == null && url != null) {
        builder.addFormDataPart("link", url);
    }

    for (int i = 0; i < pathList.size(); i++) {
       /* String s;
        if (i == 0) {
            s = "headImage";
        } else {
            s = "headImage" + i;
        }*/
        builder.addFormDataPart("headImage", System.currentTimeMillis() + ".png",
                RequestBody.create(Constant.MEDIA_TYPE_PNG, new File(pathList.get(i))));
    }
    RequestBody requestBody = builder.build();
    okhttp3.Request request = new okhttp3.Request.Builder()
            .url(ApiManager.getRequestUrl(ApiManager.PUT_TWEET))
            .post(requestBody)
            .build();

    getClient().newCall(request).enqueue(new Callback() {
        @Override
        public void onFailure(Call call, IOException e) {
            LogUtils.d(e.toString());
            sendOnFailure();
        }

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            if (response.isSuccessful()) {
                Gson gson = new Gson();
                String result = response.body().string();
                PutTweetRoot putTweetRoot = gson.fromJson(result, PutTweetRoot.class);
                if (putTweetRoot.getStatus() == ClientCode.SUCCEED) {
                    sendOnResponse();
                } else {
                    sendOnError(putTweetRoot.getStatus());
                }
            } else {
                sendOnFailure();
            }
        }
    });
@swankjesse
Copy link
Member

Could you please provide an executable test case to demonstrate the problem?

@swankjesse swankjesse added needs info More information needed from reporter bug Bug in existing code labels Jul 25, 2016
@swankjesse swankjesse modified the milestones: 3.6, Icebox Jul 25, 2016
@tianshaokai
Copy link

image
I'm using okhttp v3.3.0, and this error occured while downloading the file.

@swankjesse
Copy link
Member

No action to take on this.

@swankjesse swankjesse removed this from the Icebox milestone Nov 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in existing code needs info More information needed from reporter
Projects
None yet
Development

No branches or pull requests

3 participants