recvfrom失败:尝试上传视频时出现ETIMEDOUT

时间:2013-12-27 07:55:20

标签: java android video upload timeout

我需要将视频从应用程序上传到我们的服务器。当我尝试上传从设备相机拍摄的视频时,会发生一件奇怪的事情。它适用于一些未从相机拍摄的视频。对于摄像机视频,它只是尝试连接到服务器,一段时间后它显示以下错误。有没有人遇到过这样的问题。如果有任何解决方案,请与我分享。提前致谢。下面是错误,然后是我的代码。

java.net.SocketException:recvfrom失败:ETIMEDOUT(连接超时)

public String uploadPostCameraVideoPic() {
    // TODO Auto-generated method stub


    String responseString = null;
    String urlServer;

    urlServer = SERVERContants.URL ;


    String path = (String) mData.get(0);

    File f = new File(path);

    HttpParams httpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParams,
            SERVERContants.TIMEOUT_MILLISEC);
    HttpConnectionParams.setSoTimeout(httpParams,
            SERVERContants.TIMEOUT_MILLISEC);

    HttpClient httpclient = new DefaultHttpClient(httpParams);

    try {
        HttpPost httpost = new HttpPost(urlServer);
        MultipartEntity entity = new MultipartEntity();

        String postType = dc.getPostType(path);

        entity.addPart("name", new StringBody("videos"));
        entity.addPart("functionName", new StringBody("uploadFileAndriod"));
        entity.addPart("filename", new StringBody(path));
        entity.addPart(postType, new FileBody(f));

        httpost.setEntity(entity);
        HttpResponse response;
        response = httpclient.execute(httpost);

        System.out.println("the Resposne======" + response);
        responseString = EntityUtils.toString(response.getEntity());
        System.out.println("the responseString======" + responseString);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        System.out.println("the Exception occurs 1===== " + e.getMessage());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        System.out.println("the Exception occurs 2===== " + e.getMessage());
    }

    return responseString;
}

0 个答案:

没有答案