• General
  • LS Community edition session creation issue

I have downloaded the LS version 7.1 and in LS server configuration I have set as Community edition. And I have created adapter as like I have used in enterprise edition.
I have started LS server everything is working in server. When I try to connect the client it showing the error as like
http://localhost:8080/lightstreamer/create_session.js: Request header field username is not allowed by Access-Control-Allow-Headers in preflight response.

And also I have tried by removing the user name field from connection parameter this also not working.

This always tying to connect the LS server from client.
I have used the below code to connect, And also in server I have mentioned the javascript_client.

define(["LightstreamerClient"],function(LightstreamerClient) {
var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
var portToUse = document.location.protocol == "https:" ? "443" : "8080";
var lsClient = new LightstreamerClient(protocolToUse+"//localhost:"+portToUse,"STOCKLISTDEMO_REMOTE");
lsClient.connectionOptions.setHttpExtraHeaders({"username" : "myusername"});
lsClient.connectionOptions.setHttpExtraHeadersOnSessionCreationOnly(true);
lsClient.connect();

return lsClient;
});
Hi, This means that the access from your page to the Server is considered by the browser as a CORS request (probably because of the different port).
Consequently, the browser sends a preliminary (i.e. preflight) request to the Server to check if the latter accepts the CORS request.
However, the request is refused because of the presence of the "username" extra http header.

This can be fixed by configuring the Server to allow this header in CORS requests.
This is done in the <cross_domain_policy> block in the Server configuration file, by defining the "accept_extra_headers" attribute accordingly; it should look like:
accept_extra_headers="username"
Then restart the Server and retry (I know you succeeded).

All this matter should be independent from the edition or license with which the Server runs.