powered by Jive Software

Openfire Chat API


#21

Done.

see https://github.com/igniterealtime/openfire-chat/issues/2


#22

Where do i need to do this kind of changes of iframe.


#23

In your O/S (linux, windows, whatever server you are using)

Make sure that the machine host name matches the name showing in openfire and you can access with http://hostname:9090

This is my dev server

image


#24

Hi

Now i m accessing openfire using hostname as configured in server info but still face same issue. not able to find out issue.

Server Info

Swagger


#25

Hi @Dele_Olajide

Please have a look on that issue.

after restarting openfire server i am not able to send message into old rooms.


#26

i am still facing issue in swagger. it work in secure port. but i want to configure it as normal http bind(7070).

If i hit using http://ps-win-lp-166.thepsi.com:7070/swagger URL on browser then swagger opened but hiting any request causes no response from server. API are calling with 7443 port in swagger.

Please help me on these


#27

@Dele_Olajide

I sent message successfully using ofchat api but when i restart openfire server then i try to join same room which gives 500 error on same chat room which i sent earlier.

following steps i perform:-

  1. create chat room as room1.
  2. login to get streamid. (200 OK)
  3. join room1. (200 OK)
  4. send message to room1. (200 OK)

This send message successfully to room1.

now i restart my openfire server.
do same steps.

  1. login to get steamid (200 OK).
  2. join room1 (500 INTERNAL SERVER ERROR).

API
curl -X PUT --header ‘Authorization: 89wjjp0HBCDUAN9z’ ‘http://ps-win-lp-166.thepsi.com:7070/rest/api/restapi/v1/chat/ofchat-557815489/rooms/e2be381a-4f27-407a-9257-84f1c3bf0ac3?service=xxx’

Response
Aug 23, 2018 3:10:10 PM com.sun.jersey.spi.container.ContainerResponse logException
SEVERE: Mapped exception to response: 500 (Internal Server Error)
javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class org.jivesoftware.openfire.plugin.rest.exceptions.ErrorResponse, and Java type class org.jivesoftware.openfire.plugin.rest.exceptions.ErrorResponse, and MIME media type / was not found.

at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:284)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1510)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Unknown Source)

Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class org.jivesoftware.openfire.plugin.rest.exceptions.ErrorResponse, and Java type class org.jivesoftware.openfire.plugin.rest.exceptions.ErrorResponse, and MIME media type / was not found.

@Dele_Olajide can you please help me on this issue.


#28

3 questions for you :slight_smile:

  1. How are you creating the room?
  2. Why are you restarting the server?
  3. Do you get the same effect if you do not restart the server?

#29

I have raised an issue on this.


#30
  1. How are you creating the room?
    I am creating chat room using chat api chatroom

    curl -X POST --header ‘Content-Type: application/json’ --header ‘Authorization: 89wjjp0HBCDUAN9z’ -d ‘{ \
    “adminGroups”: [], \
    “admins”: [], \
    “broadcastPresenceRoles”: [], \
    “canAnyoneDiscoverJID”: true, \
    “canChangeNickname”: true, \
    “canOccupantsChangeSubject”: true, \
    “canOccupantsInvite”: true, \
    “creationDate”: {}, \
    “description”: “test group”, \
    “logEnabled”: true, \
    “loginRestrictedToNickname”: true, \
    “maxUsers”: 0, \
    “memberGroups”: [], \
    “members”: [], \
    “membersOnly”: true, \
    “moderated”: true, \
    “modificationDate”: {}, \
    “naturalName”: “test group”, \
    “outcastGroups”: [], \
    “outcasts”: [], \
    “ownerGroups”: [], \
    “owners”: [], \
    “password”: “123”, \
    “persistent”: true, \
    “publicRoom”: true, \
    “registrationEnabled”: true, \
    “roomName”: “test room”, \
    “subject”: “test room” \
    }’ ‘http://ps-win-lp-166.thepsi.com:7443/rest/api/restapi/v1/chatrooms?servicename=psi’

  2. Why are you restarting the server?
    There could be some reason for restarting server. Our tester test every latest build after restarting openfire server.

  3. Do you get the same effect if you do not restart the server?
    No. if i do not restart server then steps 1) login. 2) join room. 3) send message works perfectly and message sent successfully. but when i restart openfire then step 2) join room throws 500 error.


#31

Thank you for the response and answers. Just one more question. Can you replicate the error if the room is created manually in Openfire?

I am suspecting that the issue may be with the room creation. Either the configuration is not being saved properly or the room configuration has an issue.


#32

I tried with creating room manually and send message works after restarting server.

My problem is fixed now.

Issue was, i am not assigning Broadcast Presence for property while creating group.

@Dele_Olajide thanks for your help :slight_smile:


#33

Hi @Dele_Olajide i have some quetions, can you please help me on these:-

My chat message history got clear after restarting openfire server. is there any way to keep after restarting openfire server ?

How can i get unread message count of any chat room ?


#34

is there any way to keep after restarting openfire server ?

install and configure monitoring plugin.

How can i get unread message count of any chat room ?

Sorry, there is currently no chat api endpoint to do this.


#35

Sorry, there is currently no chat api endpoint to do this.

I have raised an issue to add chat room history, but the client has to check the dates to determine if the message was unread.


#36

Hi @Dele_Olajide

After taking updated code ofchat. I upload latest ofchat.jar into plugin.

It always (without restarting server) return 500 after calling joining room api from swagger.

Joining room api was working on 23 Aug committed code on git.

I created room manually from admin panel.

Request
curl -X PUT --header ‘Authorization: 89wjjp0HBCDUAN9z’ ‘http://ps-win-lp-166.xxx.com:7070/rest/api/restapi/v1/chat/ofchat180647603/rooms/mayur_room?service=psi’
Response
Aug 31, 2018 7:30:00 PM com.sun.jersey.spi.container.ContainerResponse logException
SEVERE: Mapped exception to response: 500 (Internal Server Error)
javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class org.jivesoftware.openfire.plugin.rest.exceptions.ErrorResponse, and Java type class org.jivesoftware.openfire.plugin.rest.exceptions.ErrorResponse, and MIME media type / was not found.

at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:284)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1510)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Unknown Source)

Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class org.jivesoftware.openfire.plugin.rest.exceptions.ErrorResponse, and Java type class org.jivesoftware.openfire.plugin.rest.exceptions.ErrorResponse, and MIME media type / was not found.

Please help


#37

My bad!! I deleted some code in error. It is now fixed. Pull latest code and rebuild


#38

Thanks @Dele_Olajide it is working now :slight_smile: