android - Media Player socket exception in Samsung Grand -
we playing media through local proxy server. fine till new samsung grand device. in specific device getting socket exception following:
4-04 17:55:35.646: w/system.err(15187): java.net.socketexception: sendto failed: econnreset (connection reset peer) 04-04 17:55:35.646: w/system.err(15187): @ libcore.io.iobridge.maybethrowaftersendto(iobridge.java:506) 04-04 17:55:35.646: w/system.err(15187): @ libcore.io.iobridge.sendto(iobridge.java:475) 04-04 17:55:35.646: w/system.err(15187): @ java.net.plainsocketimpl.write(plainsocketimpl.java:507) 04-04 17:55:35.656: w/system.err(15187): @ java.net.plainsocketimpl.access$100(plainsocketimpl.java:46) 04-04 17:55:35.656: w/system.err(15187): @ java.net.plainsocketimpl$plainsocketoutputstream.write(plainsocketimpl.java:269) 04-04 17:55:35.656: w/system.err(15187): @ java.io.bufferedoutputstream.flushinternal(bufferedoutputstream.java:185) 04-04 17:55:35.656: w/system.err(15187): @ java.io.bufferedoutputstream.write(bufferedoutputstream.java:139) 04-04 17:55:35.656: w/system.err(15187): @ com.ganeshane.music.gslib.comp.security.securitymanager$encryptdecryptagent.decryptstreamwithheaderandflush(securitymanager.java:192) 04-04 17:55:35.656: w/system.err(15187): @ com.ganeshane.music.gslib.comp.player.proxymediaplayer$localfileserver.handlegetrequest(proxymediaplayer.java:315) 04-04 17:55:35.656: w/system.err(15187): @ com.ganeshane.music.gslib.comp.player.proxymediaplayer$localfileserver.run(proxymediaplayer.java:291) 04-04 17:55:35.656: w/system.err(15187): caused by: libcore.io.errnoexception: sendto failed: econnreset (connection reset peer) 04-04 17:55:35.666: w/system.err(15187): @ libcore.io.posix.sendtobytes(native method) 04-04 17:55:35.666: w/system.err(15187): @ libcore.io.posix.sendto(posix.java:146) 04-04 17:55:35.666: w/system.err(15187): @ libcore.io.blockguardos.sendto(blockguardos.java:177) 04-04 17:55:35.666: w/system.err(15187): @ libcore.io.iobridge.sendto(iobridge.java:473) 04-04 17:55:35.666: w/system.err(15187): ... 8 more
our , head headers are:
head = "http/1.1 200 ok\r\n" + date + "\r\n" + "last-modified: mon, 19 jan 20013 12:51:42 gmt\r\n" + "connection: keep-alive\r\n" + "content-type: audio/mpeg\r\n" + "accept-ranges: bytes\r\n" + "server: apache/2.2.9\r\n" + "content-length: " + filelength + "\r\n" + "\r\n"; = "http/1.1 200 ok\r\n" + date + "\r\n" + "last-modified: mon, 19 jan 20013 12:51:42 gmt\r\n" + "connection: keep-alive\r\n" + "content-type: audio/mpeg\r\n" + "accept-ranges: bytes\r\n" + "server: apache/2.2.9\r\n" + "content-length: " + filelength + "\r\n" + "\r\n";
any appreciated.
so, solution encrypted mp3 files, should work other uses. issue have faced seeking when buffering not complete. sure there range end request, don't care. works 99.9% of time so...
below relevant response headers part, can find entire code @ https://gist.github.com/frostymarvelous/26ac6cba11bf50e591a4
if (cbskip > 0) {// seek or skip request if there's range // header headers += "http/1.1 206 partial content\r\n"; headers += "content-type: " + datasource.getcontenttype() + "\r\n"; headers += "accept-ranges: bytes\r\n"; headers += "content-length: " + (filesize - cbskip) + "\r\n"; headers += "content-range: bytes " + cbskip + "-" + (filesize - 1) + "/" + filesize + "\r\n"; headers += "connection: keep-alive\r\n"; headers += "\r\n"; } else { headers += "http/1.1 200 ok\r\n"; headers += "content-type: " + datasource.getcontenttype() + "\r\n"; headers += "accept-ranges: bytes\r\n"; headers += "content-length: " + filesize + "\r\n"; headers += "connection: keep-alive\r\n"; headers += "\r\n"; } log.i(tag, "headers: " + headers); outputstream output = null; byte[] buff = new byte[64 * 1024]; try { output = new bufferedoutputstream(client.getoutputstream(), 32 * 1024); output.write(headers.getbytes()); inputstream data = datasource.getinputstream(); datasource.skipfully(data, cbskip);//try skip as possible // loop long there's stuff send , client has not closed int cbread; while (!client.isclosed() && (cbread = data.read(buff, 0, buff.length)) != -1) { output.write(buff, 0, cbread); } }
Comments
Post a Comment