Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Little stuck on this, would really appreciate if someone could give me some pointers. I am receiving the following error:
Failed to parse authentication message: [SyntaxError: Unexpected token <]
Here is my nodejs.config.js
settings = {
scheme: 'http',
port: 8080,
host: 'ec2-50-18-64-89.us-west-1.compute.amazonaws.com',
resource: '/socket.io',
serviceKey: 'XXXX', // Hidden on purpose
backend: {
port: 80,
host: 'sandbox.cyac.jp',
scheme: 'http',
messagePath: '/nodejs/message'
},
debug: true,
extensions: [],
clientsCanWriteToChannels: false,
clientsCanWriteToClients: false,
transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'],
jsMinification: true,
jsEtag: true,
logLevel: 1
};
Comments
Comment #1
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI get this too.
Comment #2
stewart.adam CreditAttribution: stewart.adam commentedFor those with this problem, it is most likely because your Node.JS server is getting a HTML response when it expects a different type of data stream. To troubleshoot, set 'debug: true' in your nodejs.config.js file and then restart the server. It should print out the URL & response it gets to assist in troubleshooting.
In my case, it was because of the server returning a 401 as it expected HTTP basic auth. I achieved this by adding a header to the options object in server.js:
edit: I've patched in support for a 'httpAuth' setting in the backend options for nodejs.config.js - see #1973270: Feature: HTTP authentication support for backend URL
Comment #3
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI am uncertain how to use this.
with the settings httpAuth do I need to specify a system wide username/password with certain privileges?
Comment #4
arosboro CreditAttribution: arosboro commentedI ended up using restws's restws_basic_auth module, because my whole site redirects unauthenticated requests to /user to login. That should do the trick if you need to authenticate a drupal account with this module.
Comment #5
dynahiol CreditAttribution: dynahiol commented@arosboro how did you do that?
I've the restws_basic_auth module installed. But i've no idea how to configure it to. I'm also getting :
authenticateClientCallback: Failed to parse authentication message: [SyntaxError: Unexpected token <]
I user the httpAuth with no positive result. May be because of the logintobogan module redirecting all unauthenticated requests to /user to login.
Can you please provide to steps how you configure the restws_basic_auth module to authenticate a drupal account with this nodejs module?
Thanks.
Comment #6
kplatis CreditAttribution: kplatis commentedHello! I get the same error whenever there is a connection between the a client and the NodeJS server. The message I get in the server debug logging is:
I don't know what the problem is as there is a connection between the server and the host.
Comment #7
glekli CreditAttribution: glekli commentedThe nodejs/message path (e.g. http://yoursite.com/nodejs/message) needs to be accessible without logging in to Drupal. Certainly, if logintoboggan, or any other module, redirects from this path to the login page, that will prevent nodejs from working. Ensure that if you visit http://yoursite.com/nodejs/message in the browser, you get a json response.
Comment #8
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI ended up disabling nodejs on user/login, user/register and any other page where there might be a redirect.