title: Some cookies are misusing the recommended “sameSite“ attribute
body: <p>I'm building a react application that uses atmosphere library to listen to a <code>SpringBoot</code> <code>websocket</code>, when the client tries to connect to the server, it throws an error in the console saying <code>Some cookies are misusing the recommended “sameSite“ attribute</code>. I added some attributes to the <code>request</code> object to fix the issue as recommended (<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite" rel="nofollow noreferrer">SameSite cookies</a>). but I'm still getting the same error.</p>
  <p>ReactJS code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React from 'react';
  import * as atmosphere from 'atmosphere.js';
  
  //import $ from 'jquery';
  var transport = 'websocket';
  //var req = new atmosphere.AtmosphereRequest();
  
  // We are now ready to cut the request
  var request = {
      url:'http://localhost:8080/stream',
      contentType: "application/json",
      trackMessageLength: true,
      shared: true,
      enableXDR: true,
      headers: { 'Access-Control-Allow-Origin': '*',
                  'sameSite': ' None; Secure'
      },
      //sameSite: 'None; Secure',
      rewriteURL:true,
      transport: transport,
      fallbackTransport: 'long-polling',
      onOpen: function(response:any) {
          console.log('Atmosphere connected using ' , response.transport);
          transport = response.transport;
      },
      onTransportFailure: function(errorMsg: Atmosphere.Response, request: Atmosphere.Request) {
          console.log('Atmosphere Chat. Default transport is WebSocket, fallback is ' ,request.fallbackTransport );
      },
      onMessage: function (response:Atmosphere.Response) {
  
          var message = response.responseBody;
          try {
              console.log('message: ', message);
          } catch (e) {
              console.log('This doesn\'t look like a valid JSON: ', message);
              return;
          }
      },
      onClose : function(response: Atmosphere.Response) {
          console.log("Close connection !!!");
      }
      
  };
  
  const socket = atmosphere;
  // Connect to the server, hook up to the request handler.
  console.log('socket : ', socket.subscribe);
  socket.subscribe &amp;&amp; socket.subscribe(request);
  
  const AtmosphereWebSocket = () =&gt; {
      return ( &lt;div&gt; &lt;/div&gt; );
  }
  
  export default AtmosphereWebSocket;</code></pre>
  </div>
  </div>
  </p>
  <p>SpringBoot Code:</p>
  <pre class="lang-java prettyprint-override"><code>@Component
  @CrossOrigin(origins = &quot;http://localhost:3000&quot;)
  @WebSocketHandlerService(path = &quot;/stream&quot;, broadcaster = SimpleBroadcaster.class,
          atmosphereConfig = {&quot;org.atmosphere.websocket.WebSocketProtocol=&quot; +
                  &quot;org.atmosphere.websocket.protocol.StreamingHttpProtocol&quot;})
  public class WebSocketStream extends WebSocketStreamingHandlerAdapter {
  
      private final Logger logger = LoggerFactory.getLogger(WebSocketStream.class);
  
      public WebSocketStream() {
          System.out.println(&quot; ** WebSocketStream ** &quot;);
      }
  
      // A thread which sends a stream of data out of a websocket. Create when the class
      // is instantiated, inject the websocket when open.
      private class Stream extends Thread {
          protected WebSocket socket;
          protected final ObjectMapper mapper = new ObjectMapper();
          protected boolean stop = false;
  
          public Stream(WebSocket socket) {
              this.socket = socket;
          }
  
          public void run() {
              int count = 0;
              try {
                  while (!stop) {
                      Map&lt;String, Object&gt; message = new HashMap&lt;String, Object&gt;();
                      message.put(&quot;time&quot;, new Date().toString());
                      message.put(&quot;count&quot;, count++);
                      String string = mapper.writeValueAsString(message);
                      socket.write(string);
                      System.out.println(&quot;tick: &quot; + string);
                      Thread.sleep(1000);
                  }
              } catch (Exception x) {
                  // break.
              }
          }
      }
  
      int clients = 0;
  
      @Override
      public void onOpen(WebSocket webSocket) throws IOException {
          // Hook up the stream.
          final Stream stream = new Stream(webSocket);
          stream.start();
          logger.info(&quot; on open was called !!!&quot;);
          webSocket.broadcast(&quot;client &quot; + clients++ + &quot; connected&quot;);
          webSocket.resource().addEventListener(new WebSocketEventListenerAdapter() {
              @Override
              public void onDisconnect(AtmosphereResourceEvent event) {
                  if (event.isCancelled()) {
                      logger.info(&quot;Browser {} unexpectedly disconnected&quot;, event.getResource().uuid());
                  } else if (event.isClosedByClient()) {
                      logger.info(&quot;Browser {} closed the connection&quot;, event.getResource().uuid());
                  }
                  stream.stop = true;
              }
          });
      }
  }
  </code></pre>
  <p><strong>Error Message:</strong></p>
  <pre><code>Websocket failed on first connection attempt. Downgrading to long-        polling and resending 1.chunk.js:3632:18
  Atmosphere Chat. Default transport is WebSocket, fallback is  long-polling atmosphere.tsx:27
  The development server has disconnected.
  Refresh the page if necessary. 1.chunk.js:7419:13
  Sat Jul 11 2020 15:52:07 GMT-0500 (Central Daylight Time) Atmosphere: unload event 1.chunk.js:3632:18
  [HMR] Waiting for update signal from WDS... log.js:24
  Download the React DevTools for a better development experience: react-dom.development.js:24994
  socket :  
  function subscribe(url, callback, request)
  atmosphere.tsx:47
  Firefox can’t establish a connection to the server at ws://localhost:8080/stream?X-Atmosphere-tracking-id=0&amp;X-Atmosphere-Framework=3.0.5-javascript&amp;X-Atmosphere-Transport=websocket&amp;X-Atmosphere-TrackMessageSize=true&amp;Content-Type=application/json&amp;X-atmo-protocol=true&amp;Access-Control-Allow-Origin=*&amp;sameSite=%20None%3B%20Secure. atmosphere.js:1201
  Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent). - wasClean: false atmosphere.js:3302
  Close connection !!! atmosphere.tsx:40
  Websocket failed on first connection attempt. Downgrading to long-polling and resending atmosphere.js:3302
  Atmosphere Chat. Default transport is WebSocket, fallback is  long-polling
  </code></pre>