Uncaught error a url property or function must be specified

Describe the bug The Converse.js client works fine with BOSH, but when I switch to websockets (by enabling and specifying the websocket_url), the connection works for a short time, but then Error: ...

Hi, this looks very similar to the problem I’m facing. I also use ejabberd as the XMPP server (version 18.09). I’ve activated debug log on both conversejs-5.0.1 and ejabberd-18.09 to try to understand why the websocket connection drops after few minutes and fails to reopen afterward.
Here conversejs’s log when the problem occurs:

ERROR: Websocket closed unexpectedly converse.js:149:12388
    log https://testbed-1.gnyoi.com/conversejs/converse.js:149
    error https://testbed-1.gnyoi.com/conversejs/converse.js:149
    _onClose https://testbed-1.gnyoi.com/conversejs/converse.js:128
 2019-09-17T10:17:25.824Z DEBUG: _doDisconnect was called converse.js:149:12661
 2019-09-17T10:17:25.825Z DEBUG: WebSockets _doDisconnect was called converse.js:149:12661
 2019-09-17T10:17:25.825Z INFO: Status changed to: DISCONNECTED converse.js:149:12751
 2019-09-17T10:17:25.839Z DEBUG: <presence type="unavailable" from="5294718142784173736419@gnyoi.com/13016536059993931488435" to="forum@conference.gnyoi.com/Bob" id="6e1ea6c0-d1f7-4482-8144-6dfc093674c2:sendPresence"><status/></presence> converse.js:149:12661
 2019-09-17T10:17:25.840Z INFO: RECONNECTING: the connection has dropped, attempting to reconnect. converse.js:149:12751
 2019-09-17T10:17:25.848Z INFO: Status changed to: CONNECTING converse.js:149:12751
TypeError: this.socket is null
converse.js:128:234711
GET https://testbed-1.gnyoi.com/ws/
[HTTP/1.1 101 Switching Protocols 521ms]

 2019-09-17T10:17:26.925Z DEBUG: Websocket open converse.js:149:12661
 2019-09-17T10:17:26.925Z DEBUG: <open to="gnyoi.com" version="1.0"/> converse.js:149:12661
 2019-09-17T10:17:26.931Z DEBUG: <open xmlns="urn:ietf:params:xml:ns:xmpp-framing" id="8486992899793807183" version="1.0" xml:lang="en" from="gnyoi.com"/> converse.js:149:12661
 2019-09-17T10:17:26.934Z DEBUG: _connect_cb was called converse.js:149:12661
 2019-09-17T10:17:26.934Z DEBUG: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>ANONYMOUS</mechanism><mechanism>PLAIN</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms><register xmlns="http://jabber.org/features/iq-register"/></stream:features> converse.js:149:12661
 2019-09-17T10:17:26.934Z DEBUG: <presence type="unavailable" from="5294718142784173736419@gnyoi.com/13016536059993931488435" to="forum@conference.gnyoi.com/Bob" id="6e1ea6c0-d1f7-4482-8144-6dfc093674c2:sendPresence"><status/></presence> converse.js:149:12661
 2019-09-17T10:17:26.935Z DEBUG: <auth mechanism="PLAIN">NTI5NDcxODE0Mjc4NDE3MzczNjQxOUBnbnlvaS5jb20ANTI5NDcxODE0Mjc4NDE3MzczNjQxOQBudWxs</auth> converse.js:149:12661
 ERROR: WebSocket stream error: not-authorized converse.js:149:12388
 2019-09-17T10:17:26.940Z INFO: Status changed to: ERROR converse.js:149:12751
 2019-09-17T10:17:26.941Z DEBUG: _doDisconnect was called converse.js:149:12661
 2019-09-17T10:17:26.941Z DEBUG: WebSockets _doDisconnect was called converse.js:149:12661
 2019-09-17T10:17:26.942Z INFO: Status changed to: DISCONNECTED converse.js:149:12751
 2019-09-17T10:17:26.948Z DEBUG: <presence type="unavailable" from="5294718142784173736419@gnyoi.com/13016536059993931488435" to="forum@conference.gnyoi.com/Bob" id="7e7c54e7-5bb8-4ec3-9b27-3e0e32a80f1d:sendPresence"><status/></presence> converse.js:149:12661
TypeError: this.socket is null
converse.js:128:234711
 2019-09-17T10:17:28.948Z INFO: RECONNECTING: the connection has dropped, attempting to reconnect. converse.js:149:12751
 2019-09-17T10:17:28.960Z INFO: Status changed to: CONNECTING converse.js:149:12751
GET https://testbed-1.gnyoi.com/ws/
[HTTP/1.1 101 Switching Protocols 515ms]

 2019-09-17T10:17:29.488Z DEBUG: Websocket open converse.js:149:12661
 2019-09-17T10:17:29.489Z DEBUG: <open to="gnyoi.com" version="1.0"/> converse.js:149:12661
 2019-09-17T10:17:29.498Z DEBUG: <open xmlns="urn:ietf:params:xml:ns:xmpp-framing" id="13117055335665057913" version="1.0" xml:lang="en" from="gnyoi.com"/>

The server log at the same time (UTC+2):

2019-09-17 12:15:05.571 [debug] <0.763.0>@ejabberd_websocket:ws_loop:190 tcp connection was closed, exit
2019-09-17 12:15:05.574 [debug] <0.765.0>@mod_pubsub:node_action:3589 node_action <<"pubsub.gnyoi.com">> <<"flat">> get_entity_affiliations [<<"pubsub.gnyoi.com">>,{<<"75401492385954811991842">>,<<"gnyoi.com">>,<<"174824222595048155621858">>}]
2019-09-17 12:15:05.575 [debug] <0.765.0>@mod_pubsub:node_call:3570 node_call <<"flat">> get_entity_affiliations [<<"pubsub.gnyoi.com">>,{<<"75401492385954811991842">>,<<"gnyoi.com">>,<<"174824222595048155621858">>}]
2019-09-17 12:15:05.577 [debug] <0.765.0>@mod_pubsub:node_action:3589 node_action <<"pubsub.gnyoi.com">> <<"pep">> get_entity_affiliations [<<"pubsub.gnyoi.com">>,{<<"75401492385954811991842">>,<<"gnyoi.com">>,<<"174824222595048155621858">>}]
2019-09-17 12:15:05.582 [debug] <0.765.0>@mod_pubsub:node_call:3570 node_call <<"pep">> get_entity_affiliations [<<"pubsub.gnyoi.com">>,{<<"75401492385954811991842">>,<<"gnyoi.com">>,<<"174824222595048155621858">>}]
2019-09-17 12:15:05.584 [info] <0.765.0>@ejabberd_c2s:process_terminated:262 (websocket|<0.764.0>) Closing c2s session for 75401492385954811991842@gnyoi.com/174824222595048155621858: Connection failed: connection closed
2019-09-17 12:15:05.586 [debug] <0.765.0>@mod_carboncopy:disable:262 disabling for <<"75401492385954811991842">>
2019-09-17 12:15:05.592 [debug] <0.765.0>@mod_shared_roster:unset_presence:698 unset_presence for <<"75401492385954811991842">> @ <<"gnyoi.com">> / <<"174824222595048155621858">> -> <<"Connection failed: connection closed">> (0 resources)
2019-09-17 12:15:06.434 [info] <0.535.0>@ejabberd_listener:accept:221 (<0.784.0>) Accepted connection ::ffff:127.0.0.1:41142 -> ::ffff:127.0.0.1:5443
2019-09-17 12:15:06.465 [debug] <0.784.0>@ejabberd_http:process_header:304 ({tlssock,#Port<0.60>,#Ref<0.182672663.2372272129.221979>}) http query: 'GET' <<"/ws/">>
2019-09-17 12:15:06.465 [debug] <0.784.0>@ejabberd_http:process:391 [<<"ws">>] matches [<<"ws">>]
2019-09-17 12:15:06.467 [debug] <0.784.0>@ejabberd_websocket:connect:124 Sent handshake response : [<<"HTTP/1.1 101 Switching Protocolsrn">>,<<"Upgrade: websocketrn">>,<<"Connection: Upgradern">>,[<<"Sec-Websocket-Protocol:">>,<<"xmpp">>,<<"rn">>],<<"Sec-WebSocket-Accept: ">>,<<"xwmiVJXApVi+Tb4YB8gKuT24B7Q=">>,<<"rnrn">>]
2019-09-17 12:15:06.468 [debug] <0.785.0>@ejabberd_http_ws:init:144 Client connected through websocket {http_ws,<0.785.0>,{{0,0,0,0,0,65535,32512,1},41142}}
2019-09-17 12:15:08.921 [debug] <0.787.0>@ejabberd_http:init:149 S: [{[<<"api">>],mod_http_api},{[<<"bosh">>],mod_bosh},{[<<"upload">>],mod_http_upload},{[<<"ws">>],ejabberd_http_ws},{[<<"captcha">>],ejabberd_captcha},{[<<"admin">>],ejabberd_web_admin}]
2019-09-17 12:15:09.111 [info] <0.535.0>@ejabberd_listener:accept:221 (<0.787.0>) Accepted connection ::ffff:127.0.0.1:41144 -> ::ffff:127.0.0.1:5443
2019-09-17 12:15:09.150 [debug] <0.787.0>@ejabberd_http:process_header:304 ({tlssock,#Port<0.61>,#Ref<0.182672663.2372272129.222007>}) http query: 'GET' <<"/ws/">>
2019-09-17 12:15:09.151 [debug] <0.787.0>@ejabberd_http:process:391 [<<"ws">>] matches [<<"ws">>]
2019-09-17 12:15:09.152 [debug] <0.787.0>@ejabberd_websocket:connect:124 Sent handshake response : [<<"HTTP/1.1 101 Switching Protocolsrn">>,<<"Upgrade: websocketrn">>,<<"Connection: Upgradern">>,[<<"Sec-Websocket-Protocol:">>,<<"xmpp">>,<<"rn">>],<<"Sec-WebSocket-Accept: ">>,<<"ConMIquJt+XuDoNEZWH8fjzn1VU=">>,<<"rnrn">>]

It looks like conversejs enters a connection loop when the first websocket connection drops, failing to notice the server has accepted its re-connection.
I still have no idea why the tcp connection drops in the first place (does conversejs send keepalive packets on the websocket?) nor why conversejs fails to reconnect afterward (or at least fails to detect it has reconnected)?

Here are conversejs options I’m using (in JSON format):

    "converse": {
	"allow_contact_requests": false,
	"allow_logout": false,
	"allow_muc_invitations": false,
	"authentication": "anonymous",
	"auto_login": true,
	"auto_join_rooms": [ "forum@conference.gnyoi.com" ],
	"hide_muc_server": true,
	"jid": "gnyoi.com",
	"keepalive": false,
	"message_archiving": "never",
	"muc_disable_moderator_commands": true,
	"notify_all_room_messages": [ "forum@conference.gnyoi.com"	],
	"play_sounds": true,
	"sounds_path": "/conversejs/sounds/",
	"strict_plugin_dependencies": false,
	"trusted": "off",
	"singleton": true,
	"view_mode": "embedded",
	"websocket_url": "wss://testbed-1.gnyoi.com/ws/"
    }

ejabberd’s configuration is pretty close to the default one, it has both bosh and ws support activated, xep-0198 is also activated (not sure it is relevant here), mod_http_upload is also configured to let conversejs user upload files. I haven’t changed ejabberd configuration while upgrading to conversejs-5.0.1 and it used to work with conversejs-4.2.0.

I am currently working on the framework for a project that we have split into a web client and server code.
The client code uses a combination of require .js and backbone.js.
I’m currently working on setting up the client/server communication, and ideally we’d like to be able to use backbone’s built in .sync functionality (and the fetch call built off of it) .

However, I’m running into an odd series of errors.

As the code executes, I’m getting the following error in the console. «Uncaught Error: A «url» property or function must be specified»

These are the related shims from our main.js

require.config({
    paths: {
        'jQueryBase': '../vendor/jquery-1.10.2/jquery-1.10.2',
        'jQuery': '../vendor/jquery-ui-1.10.3/ui/jquery-ui',
        'underscore': '../vendor/underscore/underscore',
        'backbone': '../vendor/backbone/backbone',
        'handlebars': '../vendor/handlebars/handlebars-v1.1.2 '
    },
    shim: {
        'jQuery': {
            exports: '$',
            deps: ['jQueryBase']
        },
        'underscore': {
            exports: '_'
        },
        'backbone': {
            exports: 'Backbone',
            deps: ['underscore', 'jQueryBase']
        },
        'handlebars': {
            exports: 'Handlebars'
        }
    },
    waitSeconds: 0
});

This is our dogModel.js

define(['backbone'],
    function (Backbone) var DogModel = Backbone.Model.extend({

    });

    return DogModel;
});

This is our dogCollection.js

define {
    ('backbone',
        '../models/dogModel'
        J,
        function (Backbone,
            DogModel) {

            var DogCollection = Backbone.Collection.extend({
                model: DogModel,
                url: '/dogs',
            });

            return DogCollection;
        });

This is our dogData.js

define(['../collections/dogCollection',
        '../models/dogModel'
    ],
    function (DogCollection,
        DogModel) {

        var dogDataModule = {};

        dogDataModule.dogList = new DogCollection();

        //this request works
        $.ajax(
            type: "GET",
            dataType: "json",
            url: "http://localhost:7001/SERVICES/dogs",
            success: function (data) {
                dogDataArray = data;

                for (var i = 0; i < dogDataArray.length; i++) {
                    var dogData = dogDataArray[i];
                    var dogModel = new DogModel();
                    dogModel.set(dogData);
                    dogDataModule.dogList.add(dogModel);
                }
            }
        });

    //this request doesn't
    dogDataModule.dogList.sync('read', DogCollection, {
            success: function () {
                alert("success ");
            },
            error: function () {
                alert("failure ");
            }
        };

        return dogDataModule;
    });

I’ve attempted to add a URL to directly to the options of the sync request, as so:

dogDataModule.dogList.sync('read', DogCollection, {
        url: 'http://localhost:7001/SERVICES/dogs',
        success: function () {
            alert("success");
        },
        error: function () {
            alert("failure "
            };
        });

But all this does is change the error to read «Uncaught TypeError : Object function (){ return
parent.apply(this, arguments); } has no method ‘trigger'».

I’ve also attempted to add «SERVICES/» and «../SERVICES/» in front of the collection’s url property, or giving the full and explicit URL property (up to and including http://), but none of that has worked either.

Can anyone help me figure out why I am seeing this error?

Posted By: Anonymous

I know this error has come up a few times, but I’m still not sure how to make this work appropriately..

My magic begins here :

    var list_edit_member_view = new app.views.ListMemberEdit({
      el: $("#enterprise_member_list_edit_container"),
      list_ids: list_ids
    });
    list_edit_member_view.render();

And this loads this View (ListMemberEdit.js) which has this in the render() :

this.list_edit_member_view = new app.views.CollectionView({
  el: $("#enterprise_member_list_edit_container"),
  collection: app.peers,
  list_item: app.views.ListMemberEditSelection, 
  list_item_options: {list_ids: this.options.list_ids} 
});

Which loads a CollectionView view that renders its list_item_options as model views.. It is within this file (ListMemberEditSelection.js), that when I perform this.destroy, it will return :

Uncaught Error: A "url" property or function must be specified

So this makes me think that the Model or the Model URL is not being defined.. I’m just not sure where to put this since it works very similar to my other partials that are doing roughly the same thing..

Any thoughts? My apologies for the vagueness. Let me know if there’s anything else you would like to look at!

I’m curious if its possible to see where this URL attribute would be written within the Object Model or Collection itself.

Solution

This is because destroy() function will call Backbone.sync to update the server too, not only your models in the frontend. http://backbonejs.org/#Model-destroy

So, if you’re using REST to sync your data, you’ll need to set a url property in your model so Backbone know where to send request:

Backbone.Model.extend({
    url: "http://myapi.com/"
})

To allow more flexibility, you can also set a urlRoot: http://backbonejs.org/#Model-urlRoot

Answered By: Anonymous

Related Articles

  • Vue component toggle
  • Using Event Aggregator to load a view with different model…
  • backbone destroy not sending params
  • Backbone Collection.fetch gives me Uncaught TypeError:…
  • BackboneJS Rendering Problems
  • What are the undocumented features and limitations of the…
  • Backbone.js — Best Practice for Implementing «Instant»…
  • Why adding a criteria in for loop significantly improves the…
  • How to make a Vue plugin function call methods on the…
  • get data from server Backbone.js application

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Я получаю эту ошибку. Я могу преформировать чтение и удалить функции с помощью BackboneJs, но у меня возникла ошибка, когда я выполняю метод add, любая помощь будет оценена. Путь JSfiddel — http://jsfiddle.net/2wjdcgky/

BackboneJS Uncaught Error: A "url" property or function must be specified 

$(function() {

Модель

var modelContact = Backbone.Model.extend({
    defaults: function() {
        return {
            Id: 0,
            Name: "",
            Address: ""
        };
    },
    idAttribute: "Id"
});

ModelCollection

var contactCollection = Backbone.Collection.extend({
    model: modelContact,
    url: function() {
        return 'api/Contact';
    },
    add: function(model) {
        this.sync("create", model); // Error On create
    },
    remove: function(model) {
        this.sync("delete", model); //Runs Fine
    }
});
var contacts = new contactCollection;

Посмотреть

var contactView = Backbone.View.extend({
    tagName: "tr",
    events: {
        "click a.destroy": "clear"
    },
    template: _.template($("#newContacttemplate").html()),
    initialize: function() {
        this.model.on("change", this.render, this);
        this.model.on('destroy', this.remove, this);
    },
    render: function() {
        this.$el.html(this.template(this.model.toJSON()));
        return this;
    },
    clear: function(e) {
        contacts.remove(this.model); // runs fine
    }
});

Основной вид

var main = Backbone.View.extend({
    el: $("#contactApp"), 
    events: {
        "click #btnsave": "CreateNewContact"
    },
    initialize: function() {
        this.Nameinput = this.$("#contactname");
        this.Addressinput = this.$("#contactaddress");

        contacts.on("add", this.AddContact, this);
        contacts.on("reset", this.AddContacts, this);
        contacts.fetch();
    },
    AddContact: function (contact) {
        console.log("AddContact");
        var view = new contactView({ model: contact });
        this.$("#tblcontact tbody").append(view.render().el);
    },
    AddContacts: function () {
        console.log("AddContacts");
        contacts.each(this.AddContact);
    },
    CreateNewContact: function (e) {
        console.log(e);
        //Generate an error "BackboneJS Uncaught Error: A "url" property or function must be specified"
        contacts.add({ Name: this.Nameinput.val(), Address: this.Addressinput.val() });
    }
});
var m = new main;

});

Image field not working in Options page

  • Hi there,

    I’m having a strange issue on an options page in ACF Pro version 5.0.8.
    In my functions.php I added the following code to add an option page to my wp backend:

    if( function_exists('acf_add_options_page') ) {
    	acf_add_options_page(array(
    		'page_title' 	=> 'Thema Opties',
    		'menu_title'	=> 'Thema Opties',
    		'menu_slug' 	=> 'thema-opties',
    		'redirect'	=> true
    	));
    	acf_add_options_sub_page(array(
    		'page_title' 	=> 'Thema Header Opties',
    		'menu_title'	=> 'Header',
    		'parent_slug'	=> 'thema-opties',
    	));
    	acf_add_options_sub_page(array(
    		'page_title' 	=> 'Thema Footer Opties',
    		'menu_title'	=> 'Footer',
    		'parent_slug'	=> 'thema-opties',
    	));
    }

    In ACF I added a new group called ‘Header Logo’ with 2 image fields called ‘website_logo_vector’ & ‘website_logo_fallback’ with all the default settings (return value: Image Array) and assigned to the Options Page called ‘Header’.

    The fields show up correctly, and I can even upload an image with the field, but as soon as I press ‘select’ in the wordpress media manager, it just won’t insert the image. The field still says ‘Add Image’?

    I tried using the 2 fields on a plain page and that isn’t working either!
    When I add a new image field called ‘test’ on a plain page, it does work?
    Very strange… Any ideas?

    p.s. I rolled back to version 5.0.0 and that works perfectly, so I think it’s some sort of bug

  • I also have the image field not working in 5.0.8

    But it’s not on an Options page. It’s on a Custom Post Type edit screen.

    This:
    “as soon as I press ‘select’ in the wordpress media manager, it just won’t insert the image. The field still says ‘Add Image’”

    So maybe this issue effects more than just Options pages.

    Console shows:
    Uncaught Error: A "url" property or function must be specified

  • I have the same problem, and i’m using the Flexible Content with a image field inside 🙁

  • I can confirm this bug. I just updated to 5.0.8 and can’t use the image field anymore (neither on options pages nor anywhere else). Console gives me this:

    Uncaught Error: A "url" property or function must be specified

    Edit:

    Did some further testing and found out that only images <=1024 pixels width are affected. If I upload an image that’s 1025 (or more) pixels wide, it works.

    Maybe that helps.

  • Okay, here’s a quick workaround until the bug has been resolved:

    In the admin panel where the field groups and fields are defined, you have to set the preview image of each image field to “thumbnail”. After that, the upload/selection of an image won’t fail anymore. Except the uploaded image is even smaller than 150×150 pixels (the standard size of the WordPress thumbnails).

    As long as it’s larger than that, you’re fine.

  • Glad to see I’m not the only one 🙂
    I can confirm supernovae’s quick fix, however this doesn’t work with SVG images unfortunately…

  • I’m getting this error also. Was working fine until latest PRO update on Sept 13.

    Also using svg files on current project. The quick fix works for jpg/img fine but obviously not for the svgs.

    Any word on an update with proper fix?

  • Reverting to ACF5.0.7 corrected this issue for me.

    In my experience the Image field worked fine for regular custom fields, however it was breaking when Image fields were added to repeater objects.

  • Any word on an update with proper fix?

    I don’t know, are we supposed to report the bug somewhere or are the developers reading the support forums too?

  • Hi guys

    Sorry about this frustrating bug. i have found and fixed the issue and re-uploaded the plugin files.

    Please login to your ACF store account and re-download the plugin (only files changed are js/input.min.js and js/input.js)

    Thanks for your patience and help finding the bug!

    Cheers
    E

  • Thanks Elliot!
    I can confirm the fix works!

  • Awesome! Thanks a lot, Elliot.

  • Unfortunately reinstalling the plugin is not working for me. Not sure why. -Rich

  • Its not working for me too, with the last version 5.0.8 :S

  • Any further updates on this? I’ve tried to replace the plugin a few times, but it has not fixed the problem -Rich

  • @elliot maybe it helps if you change the version number for dismiss every cache problems. But I think there is some other bug. I have still some problems with the url property.

  • For anyone who is hosting with WPEngine. Be sure to turn off object / transient caching after re-uploading the plugin. This was what was causing the problem after following @elliot Condon’s instructions. After doing that, the image field started working again.

    Rich

Viewing 18 posts — 1 through 18 (of 18 total)

You must be logged in to reply to this topic.

Понравилась статья? Поделить с друзьями:
  • Uncar dll вернул код ошибки 11
  • Unc ошибка mhdd
  • Unbuckling rear belt ошибка
  • Unbound local error
  • Unb ошибка на стиральной машине haier что это означает