Net Possibility Multiplier

    primus-headless-cookie

    1.0.0 • Public • Published

    primus-headless-cookie

    A monkey-patch around http for headless Primus.createSocket to handle sticky sessions & cookies. Result of issue #452 at primus

    Usage

    var Primus = require('primus');
    var primusHsCookies = require('primus-headless-cookie');
    
    var Socket = Primus.createSocket({ transformer: transformer, parser: parser }),
        url = primusHsCookies('http://localhost:8080'),
        client = new Socket(url);
    

    How

    It basically adds a unique ID to every url used in sockets, based on this ID, it keeps a register to read Set-Cookie headers and put them back to each outgoing request. This workaround solves the problem with loadbalancers, like haproxy, which commonly uses cookies for sticky sessions.

    Install

    npm i primus-headless-cookie

    DownloadsWeekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • nec