what caused IOException and Broken pipe

瘦欲@ 提交于 2019-12-18 13:52:48

问题


My AVD is of API 15, I don't know why but the following message keeps coming up whenever I run an application on emulator. It doesn't seem to have caused any trouble except for the error message in console.

[2012-06-17 00:03:26 - ddmlib] Broken pipe
java.io.IOException: Broken pipe
    at sun.nio.ch.FileDispatcher.write0(Native Method)
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:122)
    at sun.nio.ch.IOUtil.write(IOUtil.java:93)
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:352)
    at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
    at com.android.ddmlib.Client.sendAndConsume(Client.java:575)
    at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:348)
    at com.android.ddmlib.Client.requestAllocationStatus(Client.java:421)
    at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:837)
    at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:805)
    at com.android.ddmlib.DeviceMonitor.processIncomingJdwpData(DeviceMonitor.java:765)
    at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:652)
    at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:44)
    at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:580)

What could be the cause?


回答1:


If someone uses both eclipse and android studio together, then this error will be thrown by eclipse. So even if you select the device through DDMS, its gonna throw this error.




回答2:


Old question, but still relevant and I didn't see any other answer with this information:

For me it happened when another Eclipse was running at the same time, with DDMS competing over the same socket as the eclipse trying to connect to the Android device.

Solution was to close the other Eclipse. Hope it helps someone.

Update: Probably a better solution is to edit the DDMS port of the other eclipse to something you don't use. So it's out of the race.




回答3:


This happened to me when I had both monitor and Eclipse ADT open. Try closing all Android related stuff and then do a adb kill-server && sleep 5 && adb devices and then start your tool (Eclipse/Ant/AS) again.




回答4:


'Broken pipe' means you have written data to a connection that had already been closed by the peer. Solution: don't. It is essentially an application protocol error.




回答5:


I guess that the client (Eclipse) communicate with the Server (your Emulator) by Pipe protocol (This protocol is well-know to communicate 2 process on the same machine).

The communication channel can be broken sometimes. (There are possible 100+ reason for that)

To solve this issue: restart the emulator (AVD). Maybe you will have to wait a moment (~1min??) so Eclipse can restore the Pipe channel and your Log Cat will return. Otherwise, restart both Eclipse & the emulator to get rid of this error.




回答6:


The most common reason I've had for a "broken pipe" is that one machine (of a pair communicating via socket) has shut down its end of the socket before communication was complete. About half of those were because the program communicating on that socket had terminated.

If the program sending bytes sends them out and immediately shuts down the socket or terminates itself, it is possible for the socket to cease functioning before the bytes have been transmitted and read.

Try putting pauses anywhere you are shutting down the socket and before you allow the program to terminate to see if that helps.

FYI: "pipe" and "socket" are terms that get used interchangeably sometimes.




回答7:


I noticed this happening frequently (every 5 mins or so) recently. The frequency seemed to increase if I had both a physical device and an emulator running.

Stopping the emulator and only using the physical device for debugging stopped it from happening as often - now I only see it once or twice a day.

To resolve it when it happens, you don't need to close down the emulator or reboot the device - turning USB Debugging Mode off and back on should make it show up again under adb.




回答8:


I have been struggling with this problem for a long time. Whenever I wanted to debug android mobile application with Chrome's debug tool I got disconnected every 5 mintutes.

I found out that the cause of this is indeed other process using connection to mobile phone that is running behind in OS that breaks the communication between mobile phone and OS.

I use Macbook Pro and I was running IntelliJ IDEA debugger + Android File Transfer (didn't knew this was running behind) and Chrome's debugger tool. When I closed Android File Transfer process with "Activity Monitor" tool everything was working well, no more disconnection between mobile phone and OS. My suggestion is to check always if you are running other Android process.




回答9:


I was using both Android Studio and DDMS. Closing DDMS fixed the problem for me.

Restarting Android Studio had no impact.




回答10:


In case any one else did not find any solution to this. In eclipses Neon, this happened when i had two DDMS jars in the plugins directory. I had the andmore.ddms.jar and com.android_ddms.jar. Deleting one solves the error, i guess they both compete to connect to the same port.




回答11:


restarting the android device fixed my problem




回答12:


A "Broken pipe" exception occurs when a socket connection is closed by the client on the other side. Most of the time this is nothing to worry about.




回答13:


In my case, I remove the the .android in my home directory. That's Ok.



来源:https://stackoverflow.com/questions/11065509/what-caused-ioexception-and-broken-pipe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!