Hi All, I am developing a streaming player.I need to store streamed content.So I am downloading streamed content. But I am getting exception after 5 minutes when using Wifi. W/System.err(12726): java.net.SocketTimeoutException W/System.err(12726): at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:564) W/System.err(12726): at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:88) W/System.err(12726): at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:67) W/System.err(12726): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl$LocalCloseInputStream.read(HttpURLConnectionImpl.java:167) W/System.err(12726): at com.permeative.gradio.controller.SteamingPlayer1.downloadAudioIncrement(SteamingPlayer1.java:193) W/System.err(12726): at com.permeative.gradio.controller.SteamingPlayer1$1.run(SteamingPlayer1.java:118)
My code is: public void downloadAudioIncrement(final String mediaUrl) throws IOException { final String TAG = "downloadAudioIncrement"; try{ URL url = new URL(mediaUrl); HttpURLConnection connection = null; connection = (HttpURLConnection) url.openConnection(); connection.setReadTimeout(1000 * 20); connection.setConnectTimeout(1000 * 5); connection.setDoInput(true); connection.setUseCaches(false); connection.setRequestProperty("Connection", "Keep-Alive"); connection.connect(); stream = connection.getInputStream(); if (stream == null) { Log.e(TAG, "Unable to create InputStream for mediaUrl: " + mediaUrl); } Log.i(TAG, "File name: " + downloadingMediaFile); BufferedOutputStream bout = new BufferedOutputStream ( new FileOutputStream(downloadingMediaFile), 32 * 1024 ); byte buf[] = new byte[16 * 1024]; int totalBytesRead = 0, incrementalBytesRead = 0; boolean stop = false; do { if (bout == null) { counter++; Log.i(TAG, "FileOutputStream is null, Create new one: " + DOWNFILE + counter); downloadingMediaFile = new File(context.getCacheDir(),DOWNFILE + counter); bout = new BufferedOutputStream ( new FileOutputStream(downloadingMediaFile) ); } int numread = stream.read(buf); if (numread <= 0) { System.out.println("NUMREAD LESS,SO ONCE AGAIN**************"); if(stream != null){ System.out.println("BAD STREAMING,SO TRYING ONCE AGAIN"); startStreaming(mediaUrl,64); } if(stream == null) break; } else { //Log.v(TAG, "write to file"); // bout.write(buf, 0, numread); totalBytesRead += numread; incrementalBytesRead += numread; totalKbRead = totalBytesRead/1000; System.out.println( totalKbRead); System.out.println(DateUtils.now("h:mm a")); } if ( totalKbRead >= INTIAL_KB_BUFFER && ! stop) { Log.v(TAG, "Reached Buffer amount we want: " + "totalKbRead: " + totalKbRead + " INTIAL_KB_BUFFER: " + INTIAL_KB_BUFFER); bout.flush(); bout.close(); bout = null; if(counter == 1) updateText(); // radioDumpStorer.insertMedia(downloadingMediaFile); // radioPlayer.pushFiles(downloadingMediaFile); int kbread=incrementalBytesRead/1000; // updateInterface.currentDownloadCount(counter, kbread); // updateShift(); // setupplayer(downloadingMediaFile); totalBytesRead = 0; } } while (true); stream.close(); }catch(Exception e){ e.printStackTrace(); } } It is very urgent. Please help. Thanks Kavitha -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en