title: How to solve "write ECONNABORTED" error on nodejs-websocket module?
body: <p>I have a file called <code>index.js</code> in <code>C:\users\usuario\&gt;</code><b>:</b></p>
  
  <pre><code>obj={}
  require("http").createServer((i,o)=&gt;{
  o.writeHead(200,{"content-type":"text/html"})
  o.write('&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/87/three.js"&gt;&lt;/script&gt;')
  o.write('&lt;script&gt;net=new WebSocket("ws://"+location.hostname+":9999");net.onmessage=(e)=&gt;{eval(e.data)}&lt;/script&gt;')
  o.end()
  },1).listen("8888",()=&gt;{console.log("http protocol listening")})
  require("nodejs-websocket").createServer((w)=&gt;{
  w.i=Math.floor(Math.random()*Math.pow(10,10))
  obj[w.i]={x:0,y:0,z:10,xs:0,ys:0,zs:0,r:250,g:200,b:150,s:4}
  w.sendText('k=[]')
  w.sendText('m=[]')
  w.sendText('obj={}')
  w.sendText('document.title="hypogenix"')
  w.sendText('document.body.style.margin="0"')
  w.sendText('scene=new THREE.Scene()')
  w.sendText('renderer=new THREE.WebGLRenderer()')
  w.sendText('onmousedown=onmouseup=(e)=&gt;{k[e.button]=e.type=="mousedown"}')
  w.sendText('onkeydown=onkeyup=(e)=&gt;{k[e.keyCode]=e.type=="keydown"}')
  w.sendText('setInterval(()=&gt;{'+
  'net.send("update");'+
  'for(i=0;i&lt;500;i++){if(k[i]){net.send(i)}}'+
  'for(i=0;i&lt;5;i++){if(m[i]){net.send(i)}}'+
  '},1)')
  w.sendText('camera=new THREE.PerspectiveCamera(75,1,0.1,10000)')
  w.sendText('document.body.appendChild(renderer.domElement)')
  w.sendText('render=()=&gt;{'+
  'camera.aspect=window.innerWidth/window.innerHeight;'+
  'renderer.setSize(innerWidth,innerHeight);'+
  'camera.updateProjectionMatrix();'+
  'requestAnimationFrame(render);'+
  'renderer.render(scene,camera);'+
  '}')
  w.sendText('gen=(i,x,y,z,r,g,b,s)=&gt;{obj[i]={'+
  'shape:new THREE.Mesh(new THREE.BoxGeometry(s,s,s),'+
  'new THREE.MeshBasicMaterial({color:"rgb("+r+","+g+","+b+")"}))};'+
  'scene.add(obj[i].shape)}')
  w.sendText('render()')
  w.on("error",(e)=&gt;{if(e.code!=='ECONNRESET'){throw e}})
  w.on("text",(e)=&gt;{
  if(e==37){obj[w.i].xs-=0.001}
  if(e==38){obj[w.i].ys+=0.001}
  if(e==39){obj[w.i].xs+=0.001}
  if(e==40){obj[w.i].ys-=0.001}
  if(e==17){obj[w.i].zs-=0.001}
  if(e==32){obj[w.i].zs+=0.001}
  w.sendText('camera.position.x='+obj[w.i].x)
  w.sendText('camera.position.y='+obj[w.i].y)
  w.sendText('camera.position.z='+obj[w.i].z)
  for(i in obj){w.sendText('if(obj['+i+']){'+
  'obj['+i+'].shape.position.set('+obj[i].x+','+obj[i].y+','+obj[i].z+')}'+
  'else{gen('+i+','+obj[i].x+','+obj[i].y+','+obj[i].z+','+obj[i].r+','+obj[i].g+','+obj[i].b+','+obj[i].s+')}')
  }})}).listen("9999",()=&gt;{console.log("ws protocol listening")})
  setInterval(()=&gt;{
  for(i in obj){
  obj[i].x+=obj[i].xs
  obj[i].y+=obj[i].ys
  obj[i].z+=obj[i].zs
  obj[i].xs=obj[i].xs*99/100
  obj[i].ys=obj[i].ys*99/100
  obj[i].zs=obj[i].zs*99/100
  }},1)
  gen=(x,y,z)=&gt;{obj[Math.floor(Math.random()*Math.pow(10,10))]={x:x,y:y,z:z,xs:0,ys:0,zs:0,r:200,g:200,b:200,s:1}}
  gen(4,4,4)
  gen(-4,4,4)
  gen(4,-4,4)
  gen(-4,-4,4)
  gen(4,4,-4)
  gen(-4,4,-4)
  gen(4,-4,-4)
  gen(-4,-4,-4)
  </code></pre>
  
  <p>I executed <code>node index.js</code> command, and after reloading <code>http://localhost:8888</code> no more than 5 times, the server stopped, and gaved me that error:</p>
  
  <pre><code>Error: write ECONNABORTED
  at exports._errnoException (util.js:1018:11)
  at Socket._writeGeneric (net.js:715:26)
  at Socket._write (net.js:734:8)
  at doWrite (_stream_writable.js:334:12)
  at writeOrBuffer (_stream_writable.js:320:5)
  at Socket.Writable.write (_stream_writable.js:247:11)
  at Socket.write (net.js:661:40)
  at Connection.sendText (C:\Users\usuario\node_modules\nodejs-websocket\Connection.js:142:23
  at Connection.w.on (C:\Users\usuario\index.js:50:17)
  at emitOne (events.js:96:13)
  </code></pre>
  
  <p>I want to run the index.js file, so that it works properly and will never stop. Any help? Thanks anyway.</p>