These are chat archives for fanout/pushpin

12th
Jul 2018
cd-rnukala
@cd-rnukala
Jul 12 2018 01:14
hi all
i am trying to use pushpin behind an Application Load Balancer on amazon, basically requests comes in as https on 443 & it needs to be forwarded to 7999 on pushpin server. If i don't go through Load balancer it seems to be working fine, but when i go through load balancer it is not working. Can anyone share their experience if it ever worked with a load balancer and how the setup needs to be?
when i say not working basically i dont see in the logs the request made to pushpin server or any subscriber/receiver registered
Justin Karneges
@jkarneges
Jul 12 2018 02:30
we've only used HAProxy, but I believe others have used ALB
the earliest logging is in m2adapter (m2adapter.log or "m2a" lines in combined logs), the moment a request arrives. if you don't see anything there then the problem must be earlier, maybe network access between ALB and pushpin instance
cd-rnukala
@cd-rnukala
Jul 12 2018 03:39
ok
will check that thanks for your inputs
Adrian
@picarsite
Jul 12 2018 07:29
@jkarneges Thank you for your answer. You mean "expressGrip.publish('all', new grip.WebSocketMessageFormat(message));" like in this example https://github.com/fanout/pushpin#example-using-websockets right? That also does not work.
ayurveda
@ayurved_twitter
Jul 12 2018 12:39

Anyone here able to get pushpin work with PHP publish-subscribe? I installed it via composer and even the given example code throwing tons of errors and seems vendor/autoload.php is having problem.. Is there a simpler way ?

Like client.html
publish.php

Adam McElwee
@acmcelwee
Jul 12 2018 14:39
@cd-rnukala I use an ALB. One important thing to do is make sure you have a working health check endpoint wired up.
cd-rnukala
@cd-rnukala
Jul 12 2018 14:39
ok
Adam McElwee
@acmcelwee
Jul 12 2018 14:39
Otherwise the LB won't register your pushpin nodes into the pool.
cd-rnukala
@cd-rnukala
Jul 12 2018 14:39
what is the end point checking for it?
like 7999 port
or something else?
Adam McElwee
@acmcelwee
Jul 12 2018 14:39
There isn't one, AFAIK
For us, that meant exposing a /_health endpoint on our backend app, and pushpin just proxies that request.
So our LB health check hits /_health on 7999
which proxies to our origin, and returns the response to the lb health checker
cd-rnukala
@cd-rnukala
Jul 12 2018 14:43
ok
sure
Jorge S. Cuesta
@jorgecuesta
Jul 12 2018 15:15
@cd-rnukala @jkarneges we have the same issue, you just need migrate to tcp/ssl protocols instead of http on AWS Load Balancer and also do some other steps.
but the other steps depends if you have another parts before your request is proxied to pushpin
We use pushpin on aws with kubernets
apiVersion: v1
kind: Service
metadata:
  name: pushpin
spec:
  ports:
  - name: pushpin-http
    port: 5561
    targetPort: 5561
    protocol: TCP
  selector:
    component: pushpin

---
apiVersion: v1
kind: Service
metadata:
  name: pushpin-ws
spec:
  ports:
  - name: pushpin-ws
    port: 7999
    targetPort: 7999
    protocol: TCP
  selector:
    component: pushpin
cd-rnukala
@cd-rnukala
Jul 12 2018 15:16
ok
Adam McElwee
@acmcelwee
Jul 12 2018 15:17
You can't do tcp load balancing w/ ALBs
You'd need to switch to ELB if you want TCP load balancing.
cd-rnukala
@cd-rnukala
Jul 12 2018 15:18
i see
but ALB works or AlB is nogo?
Jorge S. Cuesta
@jorgecuesta
Jul 12 2018 15:18
you need add a load balancer
Adam McElwee
@acmcelwee
Jul 12 2018 15:18
ALBs work perfectly fine, as long as you can proxy a healthcheck via http protocol.
cd-rnukala
@cd-rnukala
Jul 12 2018 15:18
ok sure
Jorge S. Cuesta
@jorgecuesta
Jul 12 2018 15:18
We made ingress-nginx
Adam McElwee
@acmcelwee
Jul 12 2018 15:18
ALBs support websockets if that's what your browser to lb protocol is.
cd-rnukala
@cd-rnukala
Jul 12 2018 15:19
browser to elb is through https
Jorge S. Cuesta
@jorgecuesta
Jul 12 2018 15:19
kind: Service
apiVersion: v1
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app: ingress-nginx
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: “cert-key-things"
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: “tcp"
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"
    service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: '3600'
spec:
  type: LoadBalancer
  selector:
    app: ingress-nginx
  ports:
  - name: http
    port: 80
    targetPort: http
  - name: https
    port: 443
    targetPort: http
cd-rnukala
@cd-rnukala
Jul 12 2018 15:19
we are forwarding 443 to 7999 on pushpin & redirects to any backend server
8080
Adam McElwee
@acmcelwee
Jul 12 2018 15:19
What transport are you using from the client?
cd-rnukala
@cd-rnukala
Jul 12 2018 15:20
this is from server we are using server sent events
from client it would just be https request
am i answering your question right?
https terminates at ELB/ALB level and then redirects to pushpin 7999 on http
Adam McElwee
@acmcelwee
Jul 12 2018 15:24
yep yep
So, yeah, ALB should be fine for you.
cd-rnukala
@cd-rnukala
Jul 12 2018 15:24
ok great thanks
Adam McElwee
@acmcelwee
Jul 12 2018 15:30
Oh, by the way, and just because I'd want someone to tell me in case I didn't know, SSE won't work for your IE/MS Edge users.
cd-rnukala
@cd-rnukala
Jul 12 2018 16:07
:)
primary use case for us is chrome users ;)
Justin Karneges
@jkarneges
Jul 12 2018 17:10
@picarsite try checking the handler logs, to make sure subscribing and publishing is occurring. you should see lines like this:
[INFO] 2018-07-12 10:06:18.800 [handler] subscribe ws://localhost:7999/ws channel=test
[INFO] 2018-07-12 10:06:31.164 [handler] publish channel=test receivers=1
Justin Karneges
@jkarneges
Jul 12 2018 17:21
Hi @ayurved_twitter , it can work without autoload but you have to write lots of requires: https://gist.github.com/jkarneges/e81eccce0bd453ce5b9aad9f0d598250
Adrian
@picarsite
Jul 12 2018 20:15
@jkarneges I don't have the publish message in the logs but I'm doing the same like in the both examples.
screen_pushpin.PNG
Adrian
@picarsite
Jul 12 2018 20:25
var app = express();
var router = express.Router();

router.use(expressGrip.preHandlerGripMiddleware);

router.all('/websocket', function(req, res, next) {
    // Reject non-WebSocket requests
    if (!expressGrip.verifyIsWebSocket(res, next)) {
        return;
    }

    // If this is a new connection, accept it and subscribe it to a channel
    let ws = expressGrip.getWsContext(res);
    if (ws.isOpening()) {
        ws.accept();
        ws.subscribe('all');
    }

    while (ws.canRecv()) {
        // Note that recv() will always return a String while recvRaw() can be
        // used to get either a String or Buffer depending on whether the
        // message is TEXT or BINARY respectively
        var message = ws.recv();

        // If return value is undefined then connection is closed
        if (message == null) {
            ws.close();
            break;
        }

        // Echo the message
        ws.send(message);
    }

    // next() must be called for the post-handler middleware to execute
    next();
});

router.post('/broadcast',
        bodyParser.text({ type: '*/*' }),
        function(req, res, next) {
    // Publish data to all clients that are connected to the echo endpoint
    var data = req.body;
    expressGrip.publish('all', new grip.WebSocketMessageFormat(data));
    res.send('Ok\n');

    // next() must be called for the post-handler middleware to execute
    next();
});

// Add the post-handler middleware to the back of the stack
router.use(expressGrip.postHandlerGripMiddleware);

app.use("/api", router);

app.listen(8080, function () {
    console.log('Example app listening on port 8080!!');
});
akash
@tHeMaskedMan981_gitlab
Jul 12 2018 20:36
hi. I am new to pushpin. I saw the docs and tried to implement test wala feature. but when I set the routes file as * test, and make a request to 7999 port, i am getting the following error :
No route for host: localhost. any idea where I am missing?