Questions tagged [node.js-stream]

A stream is an abstract interface for working with streaming data in Node.js. The stream module provides a base API that makes it easy to build objects that implement the stream interface.

There are many stream objects provided by Node.js. For instance, a request to an HTTP server and process.stdout are both stream instances.

Streams can be readable, writable, or both. All streams are instances of EventEmitter.

The stream module can be accessed using:

const stream = require('stream');

There are four fundamental stream types within Node.js:

  • Readable - streams from which data can be read (for example fs.createReadStream()).
  • Writable - streams to which data can be written (for example fs.createWriteStream()).
  • Duplex - streams that are both Readable and Writable (for example net.Socket).
  • Transform - Duplex streams that can modify or transform the data as it is written and read (for example zlib.createDeflate()).
205 questions
0
votes
2 answers

How can i play the video on web browser when i connected web server?

I made web server using node.js on Ubuntu. I want to show video When player connected with web server. index.html webserver.js var…
Hee
  • 17
  • 2
0
votes
1 answer

how to push data into mongodb using sparkfun phant?

I am new to phant and i cannot find a suitable documentation on phant using mongodb. because i have lots of data and it memory overflow occurs. and finally i fell into following error: HTTP output: { [Error: EMFILE, open…
arglee
  • 1,374
  • 4
  • 17
  • 30
0
votes
1 answer

Create a stream of XML document with declaration and doctype tags removed

Heres what Im trying to do Goal: Pipe stream of XML document with declaration and doctype tag removed. QuestionPart 1. Whats the best way to go about this. Should I use FS module's createReadStream and createWriteStream methods? Part 2. How do I…
Daniel Kobe
  • 9,376
  • 15
  • 62
  • 109
0
votes
0 answers

Node Streams: piping a reference to a stream doesn't update the original stream

Updated to better explain problem: I'm trying to build a simple proxy server module which will allow implementers to listen for and modify the response which comes from the origin server. When the proxy receives the response, I am emitting a…
Ryan Wheale
  • 26,022
  • 8
  • 76
  • 96
0
votes
1 answer

How to pause nodejs flowing stream when destination is full

$ node --version v0.10.29 Similar to "Cannot switch to old mode now" - Node.JS apn module error in tls.connect function I'm getting a "Cannot switch to old mode now" error thrown when pausing a readable stream (in this case a HTTP…
kierans
  • 2,034
  • 1
  • 16
  • 43
0
votes
1 answer

NodeJS FS Write to Read inconsistent data without overflow (Solved as Buffer.toString)

I'm using the fs.createWriteStream(path[, options]) function to create a write stream splitted in text lines each ending with \n. But, when the process ended, if I go to check the stream leater it seems to be corrupted, showing some (few) corrupted…
0
votes
1 answer

Execute when both(!) events fire .on('end')

I have a node app that reads two files as streams. I use event.on('end') to then work with the results. The problem is I don't really know how I can wait for BOTH events to trigger 'end'. What I have now is: reader1.on('end', function(){ …
gattermeier
  • 471
  • 1
  • 5
  • 11
0
votes
1 answer

Parsing header from file based stream yields unexpected results

I am writing a small parser to process some log files using node streams (io.js, actually, but I dont think that matters). I am following the example in the docs for unshift to parse out the header. I can successfully split the buffer and grab the…
Hari Seldon
  • 1,060
  • 2
  • 13
  • 27
0
votes
3 answers

passing port number as parameter in node.js

I am currently doing a project to automatically spawn new servers dynamically when the current server is overloaded. I am using node.js for creating server. I have also calculated the number of requests using a variable. Is this procedure right? Or…
Priya Samy
  • 41
  • 6
0
votes
1 answer

How do I rename the cwd, base and path in the gulp stream, to save as I need it?

I have a gulp.src stream with files: file.cwd file.base file.path D:\Projects\test D:\Projects\test\public\app\ D:\Projects\test\public\app\bootstrap-8843d1ff.js D:\Projects\test…
tamtakoe
  • 245
  • 3
  • 12
0
votes
1 answer

Limiting simultaneous piped HTTP requests in Node.js

I am writing a node script to bulk download files. In the example these are images from a file where each line has a filename and a URL. I would like this script to be scaleable up to millions of URLs to download. Node JS streams seem to be a good…
phelm
  • 71
  • 1
  • 4
0
votes
1 answer

How to write an image in Node after request() has returned

This feels like an obvious question but it's perplexing me: I want a Node function that downloads a resource at a URI. I need it to work for several different content types without the user needing to specify which type it is. I know how to pipe…
Chris Wilson
  • 6,599
  • 8
  • 35
  • 71
0
votes
4 answers

How to detect client side internet disconnection using Node.js

I am using node.js for game server . Here is my server script var net = require('net'); var http = require('http'); var host = '192.168.1.77'; var portNum = 12345;// function policy() { var xml = '\n
Liju Thomas
  • 33
  • 1
  • 11
0
votes
2 answers

writeStream - possible EventEmitter memory leak detected

I'm creating a writestream: var file = fs.createWriteStream('path', {flags: 'a+', encoding: 'utf16le'}); Using async.queue, I'm queuing this job: file.write(data, 'utf8'); file.on('error', function(error) { console.error('ERROR with file…
Udi
  • 107
  • 1
  • 11
0
votes
1 answer

Need help http Server and client server

I have used an application for login, adding friends and chat using node.js and mongoDB.I installed the node.js and monogoDB on ec2 instance. However, I do not know if need to use client server and http server? Here is the application that I used …
1 2 3
13
14