TooTallNate / node-icy

Node.js module for parsing and/or injecting ICY metadata
MIT License
291 stars 48 forks source link

timeout #33

Open renanyoy opened 7 years ago

renanyoy commented 7 years ago

how I can modify the request timeout for icy ?

StojanovicM commented 6 years ago

You can specify timeout inside options for http request. Here is exaple from my code (I use some typescript here)

import * as icy from 'icy';
import * as http from "http";
import { URL } from "url";

let url = new URL("http://www.someurl.com");

let icyRequest = icy.get({
    protocol : url.protocol,
    hostname: url.hostname,
    path : url.pathname + url.search,
    port: url.port,
    headers: { "Connection" : "close" },
    agent: false,
    timeout: 1000
}, (res) => {

    res.once('metadata', (metadata) => { let songTitle = icy.parse(metadata).StreamTitle; });

});