SnapSearch / SnapSearch-Client-Node

Node.js HTTP Client Middleware Library for SnapSearch. Search engine optimisation for single page applications.
https://snapsearch.io
MIT License
5 stars 5 forks source link

nginx https server problem #5

Closed ssageghi closed 6 years ago

ssageghi commented 6 years ago

Hi I used snapsearch and it's great thanks for that I run snapsearch and it's work fine on HTTP but when I switch to https I got a problem my error looks like this

RangeError: Invalid status code: null
    at ServerResponse.writeHead (_http_server.js:190:11)
    at ServerResponse.writeHead (/home/user/package/node_modules/on-headers/index.js:55:19)
    at ServerResponse._implicitHeader (_http_server.js:181:8)
    at ServerResponse.end (/home/user/package/node_modules/compression/index.js:102:14)
    at /home/user/package/node_modules/snapsearch-client-nodejs/src/connectInterceptor.js:72:30
    at handleResponse (/home/user/package/node_modules/snapsearch-client-nodejs/src/Client.js:104:25)
    at Request._callback (/home/user/package/node_modules/snapsearch-client-nodejs/src/Client.js:92:17)
    at Request.self.callback (/home/user/package/node_modules/snapsearch-client-nodejs/node_modules/request/request.js:122:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/home/user/package/node_modules/snapsearch-client-nodejs/node_modules/request/request.js:888:14)
    at emitOne (events.js:...

I used this

app.use(snapsearch.connect(
    new snapsearch.Interceptor(
        new snapsearch.Client('EMAIL', 'KEY'),
        new snapsearch.Detector()
    )
);

and also(if related) I use cloudflare https and i Have node js server running on nginx I hope you can help

Update

I remove https and I don't get that error but in google search console I get temporarily Unreachable did snapSearch works fine?

CMCDragonkai commented 6 years ago

I'm not sure what you mean by switching between http and https. I'm also not sure where that RangeError is coming, because I don't see that coming from SnapSearch's js client code. Not sure what you mean by google search console. If you remove snapsearch client does this error continue to happen?

ssageghi commented 6 years ago

@CMCDragonkai I mean instead of using HTTP protocol and listening to port 80 in nginx server I enabled SSL and listen to 443 port this is google search console tools for fetch website as google bot and see what it see on our website google search console or webmaster tools

if I delete snapsearch part from my server config, the site work fine, I don't have any error on the website or on the google webmaster tools. if I enabled snapserach I can't scrape my website in snapsereach.io and result is 0 content without it snapsearch scrap works correct and show more content as we expect In the error I posted earlier we can see snapsearch
like this
at /home/user/package/node_modules/snapsearch-client-nodejs/src/connectInterceptor.js:72:30

CMCDragonkai commented 6 years ago

Its possible that the connect protocol has changed, and the current interceptor middleware is not compatible anymore.

CMCDragonkai commented 6 years ago

Otherwise there's nothing that the snapsearch server is doing differently and the interceptor itself is simple. Maybe check with an older connect middleware framework, or use the explicit interception method (non-connect). Or you have to wait until someone updates this code.

ssageghi commented 6 years ago

@CMCDragonkai the problem exist if i disable ssl I used snapsearch at least a year suddenly this happen to me I don't think someone update this code anymore. Any chance that you help me to findout how snapsearch work? I really appreciate that 👍

CMCDragonkai commented 6 years ago

The fastest solution to your problem might be to try the advanced method as described in the README without using the connect middleware. You have to show how you are using connect in your index.js for me to understand where to integrate it.

ssageghi commented 6 years ago

@CMCDragonkai I used this and my problem was solved. thanks for your help 👍



var detector = new snapsearch.Detector(
    [],
    [],
    false,
    trustedProxy
);```
CMCDragonkai commented 6 years ago

What exactly was the problem?

ssageghi commented 6 years ago

@CMCDragonkai I think it's happen because of reserve proxy