what does feature not implemented response mean - xmpp

I am trying to send a custom IQ to ejabberd server from android app and I have this following class
public class IQCustom extends IQ {
public final static String childElementName = "query";
public final static String childElementNamespace = "jabber:iq:conversations";
public IQCustom(String userFrom, String server)
{
super( childElementName, childElementNamespace );
this.setType(Type.get);
setTo( server );
setFrom( userFrom );
}
#Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
xml.rightAngleBracket();
xml.halfOpenElement("abc");
xml.attribute("op","sum");
xml.rightAngleBracket();
xml.closeElement("abc");
return xml;
}
}
and these are the IQ logs I am getting:
D/SMACK: SENT (1): <iq to=‘example.com' id='BQ8wt-16' type='get'><query xmlns='jabber:iq:conversations'><abc op='sum'></abc></query></iq>
D/SMACK: RECV (1): <iq to='testing7#example.com/Smack' from='example.com' type='get' id='BQ8wt-16'><query xmlns='jabber:iq:conversations'><abc op='sum'/></query></iq>
D/SMACK: RECV (1): <r xmlns='urn:xmpp:sm:3'/>
D/SMACK: SENT (1): <iq to='example.com' id='BQ8wt-16' type='error'><error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
D/SMACK: SENT (1): <r xmlns='urn:xmpp:sm:3'/>
D/SMACK: SENT (1): <a xmlns='urn:xmpp:sm:3' h='4'/>
D/SMACK: RECV (1): <a h='5' xmlns='urn:xmpp:sm:3'/>
I understood the reason of first receive iq that I getting but I didn’t understand the reason for the iq:
D/SMACK: SENT (1): <iq to='example.com' id='BQ8wt-16' type='error'><error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
EDIT
This is the module which is supposed to act when I send the above query:
-module(mod_conversations).
-behaviour(gen_mod).
%% ====================================================================
%% API functions
%% ====================================================================
-export([start/2, stop/1, process_local_iq/3]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
-define(NS_IQ_CUSTOM, <<"jabber:iq:conversations">>).
start(Host, _) ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM, ?MODULE, process_local_iq, one_queue),
?INFO_MSG("Inside mod_conversation",[]),
ok.
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM),
ok.
process_local_iq(From,_ ,IQ) ->
From,
?INFO_MSG("Inside mod_conversation, IQ is ~p~n ",[IQ]),
Sum = 2+2,
IQ.
And Inside gen_iq_handler() I saw that handler were already registered, So I am confused now that what does implementing the feature mean.
I only want to send the value of Sum in a responding iq to the client, for that how exactly should I register this feature and how can i send a iq response from this module to the client/user without any error iq's?

Have you implemented the feature with ns xmpp-stanzas?

Related

Vertx Web Client throwing HTTP 415 Unsupported Media Type for Multipart/form-data

This service receives the multipart request from mobile client and passes on the request to downstream service for uploading the image. I am seeing 415 Unsupported Media Type in my downstream service
private void makeRequest(HttpRequest<Buffer> httpRequest,
Promise<Object> future,
RequestContext requestContext,
RoutingContext routingContext,
Entry entry) {
MultipartForm multipartForm = MultipartForm.create();
MultiMap attributes = routingContext.request()
.formAttributes();
attributes.forEach(attribute -> {
multipartForm.attribute(attribute.getKey(), attribute.getValue());
});
routingContext.fileUploads()
.forEach(fileUpload -> {
multipartForm.binaryFileUpload(fileUpload.name(), fileUpload.fileName(),
fileUpload.uploadedFileName(), fileUpload.contentType());
});
httpRequest.sendMultipartForm(multipartForm, response -> {
handleResponse(routingContext, future, response, requestContext, entry);
});
}
Getting the below exception
javax.ws.rs.NotSupportedException: HTTP 415 Unsupported Media Type
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter.getMethodRouter(MethodSelectingRouter.java:478)
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter.access$000(MethodSelectingRouter.java:94)
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter$4.apply(MethodSelectingRouter.java:779)
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter.apply(MethodSelectingRouter.java:371)
API signature of my downstream service
#POST
#Timed
#Path("{userId}/{scope}/upload")
#Consumes(MediaType.MULTIPART_FORM_DATA)
#Produces(MediaType.APPLICATION_JSON)
#ApiOperation("Multipart upload of an image")
Can someone please guide what is wrong in my code snippet or is there any setting which needs to be enabled in vertx server or vertx web client?
Thanks,
Nitish Goyal
I was able to resolve this by explicitly setting the header
.putHeader("content-type", "multipart/form-data")

Openfire Server send custom IQ to Client

I want to send Custom IQ to client, but when I route packet to client that client get error Socket closed by remote peer.
Here is my code:
List<JID> jidList = this.getUserRooms(session);
IQ iq = new IQ(Type.result);
iq.setFrom("com.innovate.ygoa");
iq.setTo(session.getAddress());
for (JID jid : jidList) {
Element item = DocumentHelper.createDocument().addElement("item");
item.setText(jid.toString());
iq.setChildElement(item);
}
XMPPServer.getInstance().getIQRouter().route(iq);
// XMPPServer.getInstance().getSessionManager().getSession(session.getAddress()).process(iq)

sleekXMPP: Get list of looged in users on XMPP Server

I am new to python & sleekxmpp scripting and would like to know how to pass this iq stanza (XEP-0133: Service administration - Get Online Users) using python (mainly the node in below stanza):
http://xmpp.org/extensions/xep-0133.html#get-online-users-list
<iq from='bard#shakespeare.lit/globe'
id='get-online-users-list-1'
to='shakespeare.lit'
type='set'
xml:lang='en'>
<command xmlns='http://jabber.org/protocol/commands'
action='execute'
node='http://jabber.org/protocol/admin#get-online-users-list'/>
</iq>
What I tried:
iq = self .make_iq_get(queryxmlns='http://jabber.org/protocol/commands', ito=self.domain, ifrom=self.jid, iq='')
response = iq.send()
print ('response = %s' % response)
Running above code in python is always resulting in IqError.
Can anyone please explain how to pass above iq stanza's xmlns, action and node information into make_iq_get ??
Please Help!!
Following code has solved my above problem:
1st line of code returns you a form to be filled, 2nd line returns a session id which is used in last line of code
iq = self['xep_0050'}.send_command(domain, "http://jabber.org/protocol/admin#get-online-users-list")
sessionid = iq['command']['sessionid']
form = self.xmpp.plugin['xep_0004'].make_form(ftype='submit')
field = form.add_field(
ftype='hidden',
type='hidden',
var='FORM_TYPE',
value=ADMIN)
field['type'] = 'hidden'
form.add_field(var='max_items', value='100')
print self['xep_0050'}.send_command(domain, "http://jabber.org/protocol/admin#get-online-users-list", sessionid=sessionid, payload=form)

Getting the JavaMail API to Work... Again

I'm working on an application that uses the JavaMail API to send an email, but I keep getting errors. I'm using Eclipse to code it and I'm using gmail to send it. I took out my real password for obvious reasons so you're probably going to need to replace that with your own if you need to experiment. Now that I've fixed some stuff thanks to you guys, I think I'm getting a timeout error because it takes a long time until it displays the error, but beyond that much, I haven't the foggiest clue. Thanks in advance for any help or advice once more.
Code:
package com.brighamcampbell.sunrisegundersonmail;
import java.io.UnsupportedEncodingException;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class Mail {
public static void main(String[] args) throws MessagingException,
UnsupportedEncodingException {
Properties mailProps = new Properties();
mailProps.put("mail.smtp.from", "butterscotchdreamer23#gmail.com");
mailProps.put("mail.smtp.host", "smtp.gmail.com");
mailProps.put("mail.smtp.ssl.trust", "smtp.gmail.com");
mailProps.put("mail.smtp.port", "465");
mailProps.put("mail.smtp.auth", true);
mailProps.put("mail.smtp.starttls.enable", "true");
Session mailSession = Session.getDefaultInstance(mailProps, new Authenticator() {
#Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("butterscotchdreamer23#gmail.com", "password");
}
});
MimeMessage message = new MimeMessage(mailSession);
//set the email sender
message.setFrom(new InternetAddress("butterscotchdreamer23#gmail.com"));
//set the email recipients
String[] emails = { "butterscotchdreamer23#gmail.com" };
InternetAddress dests[] = new InternetAddress[emails.length];
for (int i = 0; i < emails.length; i++) {
dests[i] = new InternetAddress(emails[i].trim().toLowerCase());
}
message.setRecipients(Message.RecipientType.TO, dests);
//set the email subject
message.setSubject("test");
//set the email content
message.setText("this is a test");
//send
System.out.println("sending...");
Transport.send(message);
System.out.println("done sending email!");
}
}
Error:
Exception in thread "main" javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2041)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
at javax.mail.Service.connect(Service.java:386)
at javax.mail.Service.connect(Service.java:245)
at javax.mail.Service.connect(Service.java:194)
at javax.mail.Transport.send0(Transport.java:253)
at javax.mail.Transport.send(Transport.java:124)
at com.brighamcampbell.sunrisegundersonmail.Mail.main(Mail.java:56)
Thanks for the patience!
Clearly the mail server doesn't support STARTTLS, so you shouldn't enable it.
Try removing the 3 sslfactory properties as it is not needed anymore for javamail.You should be able to connect that way.
Note:The gmail server definitely support STARTTLS:
x#test:~/$ telnet smtp.gmail.com 587
Trying 74.125.136.108...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP vv9sm12826892wjc.35 - gsmtp
EHLO me
250-mx.google.com at your service, [147.58.51.121]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
QUIT
General Gmail instructions are here, general connection debugging tips are here, and a list of common mistakes is here. Possibly you're running into a firewall or anti-virus program that's intercepting your attempt to connect. If you still can't make it work, post the JavaMail debug output.

Issue in blocking user in chatlist using smack library and open fire server

I want to block a particular friend from my chat list with XMPP. My code for doing this:
public void blockUser(String userName)
{
String listName = "newList";
List<PrivacyItem> privacyItems = new Vector<PrivacyItem>();
PrivacyItem item=new PrivacyItem(PrivacyItem.Type.jid.toString(), false, 1);
item.setValue(userName);
privacyItems.add(item);
privacyManager = PrivacyListManager.getInstanceFor(mXMPPConnection);
try
{
privacyManager.createPrivacyList(listName,privacyItems);
}
catch(Exception e)
{
Log.e("PRIVACY_ERROR: "," "+e.toString());
e.printStackTrace();
}
}
code works fine. There is no Exception, but I am not able to block a user. Can anyone help me?
Smack Logs which I got:
<main><iq type="set" id="373-3717" to="nitstest1#hostname/smack"><query xmlns="jabber:iq:privacy"><list name="newList"/></query></iq>
09-04 19:00:38.368: D/SMACK(3895): 07:00:38 PM SENT (1149259528): <iq id="373-3717" type="result"></iq>
09-04 19:00:38.658: D/SMACK(3895): 07:00:38 PM RCV (1149259528): <iq type="result" id="LvJcf-9" to="nitstest1#hostname/smack"><query xmlns="jabber:iq:privacy"><list name="newList"><item action="deny" order="1" type="jid" value="nitsquytech#hostname"/></list></query></iq></main>
You need to set the privacy list you created to be the active list.