Hazelcast REST API
Asked Answered
H

4

8

I don't get to work REST API of Hazelcast, receiving always :

  1. at client side : ERR_EMPTY_RESPONSE via Browser or java.net.SocketException: Unexpected end of file from server via a Java Test Program.
  2. at hazelcast node:

    INFO: [myIP]:5701 [dev] [3.6] Established socket connection between /127.0.0.1:5701 and /127.0.0.1:62816
    06-may-2016 13:04:20 com.hazelcast.nio.tcp.TcpIpConnection
    INFO: [myIP]:5701 [dev] [3.6] Connection [/127.0.0.1:62816] lost. Reason: Socket explicitly closed
    

The used code is just hazaelcast multimap sample: and the REST API uri http://localhost:5701/hazelcast/rest/maps/my-distributed-map/key

Heterograft answered 6/5, 2016 at 11:7 Comment(6)
Do you try to access a multimap? Multimaps are not supported, only cluster information, maps and queues.Falkner
Just a map, like the sample program: ConcurrentMap<String, String> map = h.getMap("my-distributed-map") and also IMap, Multimap ...always the same responseHeterograft
Is the REST available? By default it should be disabled after 3.6.Aoristic
@Murat, you are OK. The same sample with 3.5.2 works fine.... I dont know how to enable. I have tried "hazelcast.mc.rest.enabled", but nothingHeterograft
The correct property to enable REST is: -Dhazelcast.rest.enabled=true . This way works after 3.6Heterograft
Cheers. hazelcast.mc.rest.enabled is for Management Center REST imho.Aoristic
B
10

i think that REST interface was disabled by default until certain version. add jvm argument for your application.

-Dhazelcast.rest.enabled=true
Boggle answered 5/12, 2016 at 23:54 Comment(1)
Faced a similar issue after upgrading from hazelcast 3.5 to 3.7.Presentday
P
4

You can add hazelcast.rest.enabled to your hazelcast.xml config.

<hazelcast>
   ...
  <properties>
    ...
    <property name="hazelcast.rest.enabled">true</property>
  </properties> 
</hazelcast>
Presentday answered 13/7, 2017 at 21:6 Comment(0)
M
4

If you want to do it programatically, for example using Spring Boot @Configuration Bean, use this method on your returned com.hazelcast.config.Config class:

.setProperty("hazelcast.rest.enabled", "true")
Mahaliamahan answered 8/8, 2017 at 21:2 Comment(0)
S
3

The property hazelcast.rest.enabled was removed in Hazelcast 4.

If you wish to do this programatically in Hazelcast 4, you can use the REST endpoint groups

RestApiConfig restApiConfig = new RestApiConfig()
        .setEnabled(true)
        .enableGroups(RestEndpointGroup.DATA);
config.getNetworkConfig().setRestApiConfig(restApiConfig);

Or in the declarative configuration

<hazelcast>
    ...
    <network>
        <rest-api enabled="true">
            <endpoint-group name="DATA" enabled="true"/>
        </rest-api>
    </network>
</hazelcast>
Suspensory answered 24/3, 2021 at 12:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.