Project

General

Profile

Restful API problems

Mike Jiang
Added about 4 years ago

I deployed tigase-server-7.0.0-SNAPSHOT.jar, and configed init.properties like followings:

---------------- init.properties --------------

@--virt-hosts = xxxxxx
--auth-db-uri = jdbc:mysql://xxxxxx/tigasedb?user=tigase&password=tigase12&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
--user-db-uri = jdbc:mysql://xxxxxx/tigasedb?user=tigase&password=tigase12&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8 
--user-db = mysql
--admins = admin
--auth-db = tigase-auth
config-type = --gen-config-all
--cluster-mode = false
--comp-class-7 = tigase.http.HttpMessageReceiver
--comp-name-7 = http
--comp-class-6 = tigase.archive.MessageArchiveComponent
--comp-name-6 = message-archive
--comp-class-5 = tigase.http.rest.RestMessageReceiver
--comp-name-5 = rest
rest/use-local-server[B]=true
#--comp-class-4 = tigase.stun.StunComponent
#--comp-name-4 = stun
--comp-name-3 = proxy
--comp-class-3 = tigase.socks5.Socks5ProxyComponent
--comp-name-2 = pubsub
--comp-class-2 = tigase.pubsub.PubSubComponent
--comp-name-1 = muc
--comp-class-1 = tigase.muc.MUCComponent
#--debug = server,xmpp.impl,db,util,muc,component
--debug = server,http,rest,xmpp
--sm-plugins = +message-archive-xep-0136,+jabber:iq:auth,+urn:ietf:params:xml:ns:xmpp-sasl,+urn:ietf:params:xml:ns:xmpp-bind,+urn:ietf:params:xml:ns:xmpp-session,+jabber:iq:register,+jabber:iq:roster,+presence,+jabber:iq:privacy,+jabber:iq:version,+http://jabber.org/protocol/stats,+starttls,+msgoffline,+vcard-temp,+http://jabber.org/protocol/commands,+jabber:iq:private,+urn:xmpp:ping,+basic-filter,+domain-filter,+pep,+zlib
#if finish debug, turn this option on
--vhost-tls-required = true
#http restful api config
--api-keys=xxxxxxxxxxxxxxxxxxxxxxx
http/rest/active[B]=true@

when I send request via curl like this,

curl -H "Content-type: text/xml" -H "Api-Key: xxxxxx" -u "admin:xxxxx" http://localhost:8080/rest/adhoc/sess-man@localhost -d "<command><node>http://jabber.org/protocol/admin#announce</node><fields><item><var>from-jid</var><value>admin</value></item><item><var>subject</var><value>abc</value></item><item><var>msg-type</var><value>chat</value></item><item><var>announcement</var><value>this is abody</value></item></fields></command>"

this request hangs up here. I grep the log file found this error:

......

2015-01-14 16:52:45.410 [in_15-message-router]  MessageRouter.processPacket()  FINEST:  Possible infinite loop, dropping packet: from=sess-man@localhost, to=sess-man@localhost, DATA=<iq id="779cb65e-e955-44f5-
bede-6bb1a1e46c93" from="sess-man@localhost" to="admin" type="error"><command node="http://jabber.org/protocol/admin#announce" xmlns="http://jabber.org/protocol/commands"><x type="submit" xmlns="jabber:x:
data"><field var="from-jid"><value>admin</value></field><field var="subject"><value>abc</value></field><field var="msg-type"><value>chat</value></field><field var="announcement"><value>this is abody</value></
field></x></command><error type="cancel" code="501"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" xml:lang="en">There is no
implementation for such command on the server.</text></error></iq>, SIZE=703, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=error
......
2015-01-14 16:52:45.412 [in_10-sess-man]   SessionManager.processPacket()     INFO:     Impossible happened, please report to developer packet: from=http@localhost/02abf27f-97c4-47b2-8ca9-85dfc44d7ecf, to=sess-
man@localhost, DATA=<iq from="admin" id="779cb65e-e955-44f5-bede-6bb1a1e46c93" to="sess-man@localhost" type="set"><command node="http://jabber.org/protocol/admin#announce" xmlns="http://jabber.org/protocol/
commands"><x type="submit" xmlns="jabber:x:data"><field var="from-jid"><value>admin</value></field><field var="subject"><value>abc</value></field><field var="msg-type"><value>chat</value></field><field
var="announcement"><value>this is abody</value></field></x></command></iq>, SIZE=462, XMLNS=null, PRIORITY=NORMAL, PERMISSION=ADMIN, TYPE=set, connection: XMPPResourceConnection=[user_jid=sess-man@localhost,
packets=1, connectioId=null, domain=localhost, authState=NOT_AUTHORIZED, isAnon=false, isTmp=false].

Please help me here, I struggled this problems for days. Thanks a lot.


Replies (10)

Added by Wojciech Kapcia TigaseTeam about 4 years ago

Do you have all libraries, including goorvy libraries? Are the admin scripts in the correct path and are loaded by the Tigase? You should have following line in your logs/tigase.log.x file:

BasicComponent.loadScripts()       CONFIG:   sess-man: Loaded admin command from file: src/main/groovy/tigase/admin/BroadcastToOnline.groovy, id: http://jabber.org/protocol/admin#announce, ext: groovy, descr: Send Announcement to Online Users

Added by Mike Jiang about 4 years ago

Yes, I installed all libraries including groovy libraries. Log file logs/tigase.log.0 has this line:

2015-01-14 19:05:02.762 [main] BasicComponent.loadScripts() CONFIG: sess-man: Loaded admin command from file: scripts/admin/BroadcastToOnline.groovy, id: http://jabber.org/protocol/admin#announce, ext: groovy, descr: Send Announcement to Online Users

It looks like that loading BroadcastToOnline.groovy is ok.

Added by Mike Jiang about 4 years ago

Wojciech Kapcia wrote:

Do you have all libraries, including goorvy libraries? Are the admin scripts in the correct path and are loaded by the Tigase? You should have following line in your logs/tigase.log.x file:

[...]

Yes, I installed all libraries including groovy libraries. Log file logs/tigase.log.0 has this line:

2015-01-14 19:05:02.762 [main] BasicComponent.loadScripts() CONFIG: sess-man: Loaded admin command from file: scripts/admin/BroadcastToOnline.groovy, id: http://jabber.org/protocol/admin#announce, ext: groovy, descr: Send Announcement to Online Users

It looks like that loading BroadcastToOnline.groovy is ok.

Added by Wojciech Kapcia TigaseTeam about 4 years ago

Another thing - you have HTTP-API component loaded twice - older (1.0.0) and newer (1.1.0) version:

--comp-class-7 = tigase.http.HttpMessageReceiver
--comp-name-7 = http
--comp-class-5 = tigase.http.rest.RestMessageReceiver
--comp-name-5 = rest

You should use only newer one (@HttpMessageReceiver@).

In the form you should also provide full jid in the From field:

<item><var>from-jid</var><value>admin</value></item>

Added by Mike Jiang about 4 years ago

Wojciech Kapcia wrote:

Another thing - you have HTTP-API component loaded twice - older (1.0.0) and newer (1.1.0) version:

[...]

You should use only newer one (@HttpMessageReceiver@).

In the form you should also provide full jid in the From field:

[...]

I modified my init.properties as you said, and revised the curl request.

But I still found same error in logs/tigase.log.0

@2015-01-14 20:05:17.289 [in_46-sess-man] SessionManager.processCommand() WARNING: There is no implementation for such command on the server: from=sess-man@localhost, to=null, DATA=<iq id="0e138d60-0442-

4030-90a4-365fb1795b4b" from="admin@172.18.8.53" type="set" to="sess-man@localhost"><x type="submit"

xmlns="jabber:x:data">admin@172.18.8.53abcchat<field

var="announcement">this is abody, SIZE=486, XMLNS=null, PRIORITY=NORMAL, PERMISSION=LOCAL, TYPE=set

2015-01-14 20:05:17.291 [in_8-message-router] MessageRouter.processPacket() FINEST: Processing packet: from=sess-man@localhost, to=sess-man@localhost, DATA=<iq id="0e138d60-0442-4030-90a4-365fb1795b4b"

from="sess-man@localhost" type="error" to="admin@172.18.8.53"><field

var="from-jid">admin@172.18.8.53abcchatthis is abody</

field>There is no

implementation for such command on the server., SIZE=727, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=error

2015-01-14 20:05:17.298 [in_8-message-router] MessageRouter.processPacket() FINEST: Possible infinite loop, dropping packet: from=sess-man@localhost, to=sess-man@localhost, DATA=<iq id="0e138d60-0442-4030-

90a4-365fb1795b4b" from="sess-man@localhost" type="error" to="admin@172.18.8.53"><x type="submit"

xmlns="jabber:x:data">admin@172.18.8.53abcchat<field

var="announcement">this is abody<text xml:lang="en" xmlns="urn:ietf:

params:xml:ns:xmpp-stanzas">There is no implementation for such command on the server., SIZE=727, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=error@

Added by Wojciech Kapcia TigaseTeam about 4 years ago

Ok, one more thing - you should also have correct admin user. Right now you have --admins = admin which is not valid, you should add --virt-hosts = xxxxxx to it, i.e. admin@xxxxxx and use the same user to execute ad-hoc.

Added by Mike Jiang about 4 years ago

Wojciech Kapcia wrote:

Ok, one more thing - you should also have correct admin user. Right now you have --admins = admin which is not valid, you should add --virt-hosts = xxxxxx to it, i.e. admin@xxxxxx and use the same user to execute ad-hoc.

Thanks for your patience. I changed admins options --admins = admin@172.18.8.53 . Now, I found the following curl request is processed and returned correct response, just as listed here [[[https://projects.tigase.org/projects/tigase-http-api/wiki/Usage_examples]]]

curl -H "Content-type: text/xml" -H "Api-Key: xxxxxxxxx" -u "admin@172.18.8.53:admin@tigase_dev" http://localhost:8080/rest/adhoc/sess-man@localhost

But if curl with following command, unfortunately, the same error remains.

curl -H "Content-type: text/xml" -H "Api-Key: xxxxxxxxx" -u "admin@172.18.8.53:admin@tigase_dev" http://localhost:8080/rest/adhoc/sess-man@localhost -d "<command><node>http://jabber.org/protocol/admin#announce</node><fields><item><var>from-jid</var><value>admin@172.18.8.53</value></item><item><var>subject</var><value>abc</value></item><item><var>msg-type</var><value>chat</value></item><item><var>announcement</var><value>this is abody</value></item></fields></command>"

Added by Wojciech Kapcia TigaseTeam about 4 years ago

Let's step back. Are you able to login to the Tigase using regular XMPP client (Psi for example) using username=@admin@172.18.8.53@ and password = @admin@tigase_dev@? If yes, can you execute the broadcast command from it (sample steps can be found here but instead fro statistics you need to Session Manager component)

Added by Mike Jiang about 4 years ago

Wojciech Kapcia wrote:

Let's step back. Are you able to login to the Tigase using regular XMPP client (Psi for example) using username=@admin@172.18.8.53@ and password = @admin@tigase_dev@? If yes, can you execute the broadcast command from it (sample steps can be found here but instead fro statistics you need to Session Manager component)

Thanks for you reply today. I tried Psi, and browsed the service discovery list, and retrieved running statistics from server. BUT I found HTTP Server Integration Module, and I clicked into this node, and double clicked REST support node, the window popped up with only one option "Reload REST HTTP Script". I think it's abnormal.

Added by Wojciech Kapcia TigaseTeam about 4 years ago

Mike Jiang wrote:

Thanks for you reply today. I tried Psi, and browsed the service discovery list, and retrieved running statistics from server. BUT I found HTTP Server Integration Module, and I clicked into this node, and double clicked REST support node, the window popped up with only one option "Reload REST HTTP Script". I think it's abnormal.

It's correct - for the http rest component you have only such script available. Nevertheless you should navigate to Service Discovery -> Session Manager -> double click or select Execute command from context menu -> Broadcast message…

    (1-10/10)