Search code examples
hazelcastspring-session

Hazelcast and Spring Session: REST API returns epmty values


I try to integrate Spring Session and Hazelcast. I am using very simple configuration:

 com.hazelcast.config.Config cfg = new com.hazelcast.config.Config();
    NetworkConfig netConfig = new NetworkConfig();
    netConfig.setPort(SocketUtils.findAvailableTcpPort());
    System.out.println("Hazelcast port #: " + netConfig.getPort());
    cfg.setNetworkConfig(netConfig);
    SerializerConfig serializer = new SerializerConfig().setTypeClass(Object.class)
            .setImplementation(new ObjectStreamSerializer());
    cfg.getSerializationConfig().addSerializerConfig(serializer);
    return Hazelcast.newHazelcastInstance(cfg);

It is from Spring docs example. Everything ok, but when I try to get session from Hazelcast with its Rest APi it returns empty values 0curl: (52) Empty reply from server

$ curl -X GET http://localhost:port/hazelcast/rest/maps/spring:session:sessions/session-id

Where port is port, selected with SocketUtils.findAvailableTcpPort() and session-id is session id in browser.

How I can access my saved sessions with Hazelcast REST API?

Update:

By adding cfg.setProperty("hazelcast.rest.enabled","true"); all problems disappeared.


Solution

  • You have to activate the REST API service which is disabled by default (for security reasons). Please see http://docs.hazelcast.org/docs/3.6/manual/html-single/index.html#system-properties and search for hazelcast.rest.enabled.